I'm converting some old work to mysqli, and having a bit of trouble with Prepared Statements.
In the stripped down code sample below, I'm able to confirm that the code below pulls the records; line 8 echoes the string as expected and if I replace the id parameter with something like lastname = smith to pull multiple records I get the correct number of lines echoed. This suggests that my query and prepared statement are working properly.
Problem is, I don't know how to access the data. Stupid, I know. I did this sort of thing all the time in the old mysql extension and something like $row['lastname'] gave it up, but in mysqli I haven't a clue.
Can someone help me out here?
if ($stmt = $db -> prepare("SELECT * FROM members WHERE id = ?")) {
// bind parameters, execute the statement, ...
$stmt -> bind_param("s", $id);
$stmt -> execute();
$stmt -> bind_result($result);
// fetch the value
while($stmt -> fetch()){
echo "...<br />";
}
// close statement
$stmt -> close();
}