I\'m using a prepared statement to SELECT *
from a MySQL table and I\'m not sure how to use while($row = mysqli_fetch_array($stmt))
to loop through
Dunno if anyone will be interested in the proper answer for this already answered and accepted question, but what the heck.
To answer your question using mysqli, you have to use get_result()
So, the proper mysqli-based solution will be
$query = "SELECT * from `wp_posts` WHERE ID=? ";
$stmt = $mysqli->prepare($query);
$stmt->bind_param("i", $pid);
$stmt->execute();
$res = $stmt->get_result();
$data = $res->fetch_all(MYSQLI_ASSOC);
(the full explanation for this code can be found in my article, Mysqli SELECT query with prepared statements)
and then you can use $data in the foreach loop for the output as it showed in the other answer.