I am using OO prepared statement. I need to count the number of rows returned and echo out the rows. But the problem is that i can only echo $stmt->num_row only if I include $stmt->store_result(). But if I include $stmt->store_result(), i can't echo out the rows. Below is my script.
Code: Select all
//THIS WILL ECHO THE num_rows BUT WILL NOT ECHO THE DATA FROM THE DB TABLE
$get_user = $conn->prepare("SELECT * FROM realtors_admins WHERE realtor=? ORDER BY unik DESC");
$get_user->bind_param('s', $remail);
$get_user->execute();
$get_user->store_result();
$result = $get_user->get_result();
echo $get_user->num_rows.".";
while ($row = $result->fetch_assoc()) {
echo .$row['fname']." ".$row['lname'];
}
Code: Select all
//THIS WILL NOT ECHO num_rows BUT WILL ECHO THE DATA FROM THE DB TABLE
$get_user = $dWay->prepare("SELECT * FROM realtors_admins WHERE realtor=? ORDER BY unik DESC");
$get_user->bind_param('s', $remail);
$get_user->execute();
$result = $get_user->get_result();
echo $get_user->num_rows.".";
while ($row = $result->fetch_assoc()) {
echo .$row['fname']." ".$row['lname'];
}
Thanks