Hi all !
I have a piece of code here:
$result = display_all(fcon, $var1, $var2);
function display_all( // defined in another file
$query = "SELECT one, two, three four, index1, index2 FROM numbers WHERE index1 = $var1 LIMIT 0, 1"; $result = mysqli_query($fcon, $query); return ($result); )
and then I use the returned variable $result to display the value as follows:-
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
{
echo "<tr>";
echo "<td>".$one."</td>";
echo "<td>".$two."</td>";
echo "<td>".$three. "</td>";
echo "<td>".$four. "</td>";
echo "<td>".$index1. "</td>";
echo "</tr>";
}
and this displays the n rows of data returned.
Now I have started using prepared statements and the function is now
function display_all{
$query = "SELECT one, two, three four, index1 FROM numbers WHERE index1 = ?
LIMIT 0, 10";
$stmt = $conn->prepare($query);
$stmt->bind_param('i',$var)
if($stmt->execute())
{
$stmt->bind_result($one, $two, $three, $four, $index1);
$stmt->store_result();
}
return($stmt);
}
However the returned $stmt object is unable to display the n rows of data since it shows null values. I assume that this is not the right way to use the $stmt object to display data. I must be missing something. So I request you guys to help me with this.
Thanks loads.