$stmt-num_rows ( Return 0 )
<p>i am just trying to learn prepared statement and i am following the PHP manual to guide me through, i have checked the answers regarding this problem on stackoverflow but, i can't find any solutions, the $stmt->num_rows always ( Return 0 ) </p>

<p>there is a post on stackoverflow discussed the problem and they advised to use 
$stmt->store_result() just before the $stmt-num_rows, but the $stmt->num_rows return 0 </p>

<p>some one please can tell me what i am doing wrong here.... i am just sick of the procedural style coding and i want to enhance my skills with prepared statement</p>

<p>here is the function down below</p>

<pre><code>function get_all()
    {
        // ** Initializing  the Connection
        $mysqli = Connect();
        $sql = ( ' SELECT * FROM `users` ' );
        $stmt = $mysqli-&gt;prepare($sql);
        $stmt-&gt;execute();
        $res = $stmt-&gt;get_result();
        echo $num_count = $stmt-&gt;num_rows();
        $user = array();
        for ($counter = 0; $row = $res-&gt;fetch_assoc(); $counter++) 
        {
            $user[$counter] = $row;
        }   
        return $user;
    }
</code></pre>

<p>// This is the second update</p>

<pre><code>function get_all()
    {
        // ** Initializing  the Connection
        $mysqli = Connect();

        $sql = ( ' SELECT * FROM `users` ' );

        $stmt = $mysqli-&gt;prepare($sql);

        $stmt-&gt;execute();

        $res = $stmt-&gt;get_result();

        echo $num_count = $stmt-&gt;num_rows;

        $user = array();

        while($row = $res-&gt;fetch_assoc()) 
        {
             $user[] = $row;
        }


         return $user;

    }
</code></pre>

<p>// third update </p>

<pre><code>function get_alll()
    {

        // ** Initializing  the Connection
        $mysqli = Connect();

        // no need to use * character, 
        // need to write query this way
        $sql = ( ' SELECT `id`,`fname`,`lname`,`uname`,`email` FROM `users` ' );

        $stmt = $mysqli-&gt;prepare($sql);
        // here need to use bind param
        $stmt-&gt;bind_result( $id, $fname, $lname, $uname, $email);
        $stmt-&gt;execute();
        // it's important to store the result 
        // before using num rows    
        $res = $stmt-&gt;store_result();

        echo $num_count = $stmt-&gt;num_rows;

            // 
        while($stmt-&gt;fetch())
        {
            echo $fname;
        }

     }
</code></pre>
