Arash Arash - 1 year ago 113
PHP Question

How to convert mysql_result to mysqli result in this example

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

Answer Source

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"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download