I am totally new to this PHP.
I am just practicing Prepared statements. I know there few questions which is related to mine.
But nothing Helped me.
This is my php code Which returns always num_rows
equal to Zero.
But there is a data in my table
if (isset($_POST['submit'])) {
$my_id = 49;
$content = $_POST['cont'];
$content_date = date('d-m-y');
$check = "SELECT * FROM post WHERE user_id = ?";
$stmt = $con->prepare($check);
$stmt->bind_param("i",$my_id);
$stmt->execute();
$stmt->fetch();
$numberofrows = $stmt->num_rows;
$stmt->close();
echo '<h1>'.$numberofrows.'</h1>';
}
Use () look like this... $numberofrows = $stmt->num_rows(); and try.
Guys Thanx For your Ans Finally My friend helped me to solve this. We have to store the result before we calling num_rows
$stmt->store_result();
It works fine now
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.