1

I want to fetch this result from the database that i've already created and has value i've added. After researching some old codes (1 yr ago) and searching at stackoverflow. I'm using this source: how to fetch all the row of the result in php mysql?

I tried with same writing code, and the results never shown. Already tried to troubleshoot by: - Checking it's number of row by using mysqli_num_rows and find 2 rows and that is correct. - Reverse if from ($count > 0) to ($count < 0), and it seems no logical problem

    <?php

    $query_call = "SELECT * FROM ass";
    $result = mysqli_query($conn, $query_call) or die(mysqli_error($conn));
    $count = mysqli_num_rows($result);
    if (mysqli_num_rows($result))
    {
        while ($row = mysqli_fetch_assoc($result));
        {
            //echo "Double";

            echo $row['stand'];


        }
    }
    else
    {
        echo "<tr><td colspan='7'>Data Did not found</td></tr>";
    }


    ?>

The result i want is as same as the value that stored at database.

2
  • 3
    i think its a typo.remove the ; in the while loop.Do like this while ($row = mysqli_fetch_assoc($result)){ //do stuff } Commented Apr 29, 2019 at 6:07
  • thanks for the correction, my bad i wasn't notice that semicolon. Commented Apr 29, 2019 at 6:13

1 Answer 1

1

Map your code like this,

$mysqli = new mysqli("localhost", "my_user", "my_password", "db_name");
$query_call = "SELECT * FROM ass";
if ($result = $mysqli->query($query_call)) {
    /* fetch associative array */
    while ($row = $result->fetch_assoc()) {
        printf ("%s\n", $row["stand"]);
    }
    /* free result set */
    $result->free();
} else {
    echo "<tr><td colspan='7'>Data Did not found</td></tr>";
}

It should work.

I mapped your snippet with official documentation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.