I understand how to fetch a result in mysqli, but how would this example be coded for mysqli?
for ($i = 0; $i < $num_rows; $i++) {
$uname = mysql_result($result, $i, "username");
$email = mysql_result($result, $i, "email");
echo "<tr><td>$uname</td><td>$email</td></tr>\n";
}
Thanks for taking a look
Assuming you've converted your other calls to return $result
as a mysqli_result
object, the most efficient way to do this would probably be
while ($row = $result->fetch_assoc())
{
echo "<tr><td>{$row['username']}</td><td>{$row['email']}</td></tr>\n";
}
You can do like this:
for ($i = 0; $i < $num_rows; $i++) {
$row = mysqli_fetch_assoc($result);
$uname = $row["username"];
$email = $row["email"];
echo "<tr><td>$uname</td><td>$email</td></tr>\n";
}
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.