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
Here is a simple example of a 'prepared select statement' and echoing out the result.
if($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['uname']) && isset($_POST['pword'])) {
$stmt = $conn->prepare("SELECT * FROM members WHERE username = ? && password = ?");// substitute '$conn' with whatever you named your database connection.
$stmt->bind_param("ss", $username, $password);
$username = $_POST['uname'];
$password = $_POST['pword'];
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows ===0) exit('Not-A-Thing');
while($row = $result->fetch_assoc()) { echo $row['id'] . "
" . $row['username']; }
$stmt->close();
}
This is just an example. If you were searching for how to bind parameters, then you more than likely already know what the '?'s and 'ss's mean. No explanation should be needed if you have previously queried a database before.