0
<?php

if (isset($_GET['flyerID']))
    $FlyerID = $_GET['flyerID'];

$DBConnect = @mysqli_connect("host", "UN", "pword")

    Or die("<p>Unable to connect to the datbase server.</p>" . "<p>Error Code ".mysqli_connect_errno().": ".mysqli_connect_error()) . "</p>";

$DBName = "agentsleuthdb";

@mysqli_select_db($DBConnect, $DBName)

    Or die("<p>Unable to select the database.</p>" . "<p>Error Code " . mysqli_errno($DBConnect) . ": " . mysqli_error($DBConnect)) ."</p>";

    $TableName = "FEEDBACK";

    $SQLstring = "SELECT * FROM $TableName order by FIRSTNAME";

    $QueryResult = @mysqli_query ($DBConnect, $SQLstring)

    Or die("<p> Unable to exequte Select query.</p>"."<p>Error Code ".mysqli_errno($DBConnect) .": ".mysqli_error

($DBConnect))."</p>";

    if (mysqli_num_rows($QueryResult) == 0){

        exit("<p>There is no feedback</p>");
}

?>


            <table border="1">
                <tr>
                    <th width = "15%">First Name </th>
                    <th width = "15%">Last Name </th>
                    <th width = "15%">Email Addr </th>
                    <th width = "15%">Company </th>
                    <th width = "40%">Feedback </th>

                </tr>


<?php
    $Row = mysqli_fetch_row($QueryResult);

do {
    echo "<tr><td>{$Row[0]}</td>";
    echo "<td>{$Row[1]}</td>";
    echo "<td>{$Row[2]}</td>";
    echo "<td>{$Row[3]}</td>";
    echo "<td>{$Row[4]}</td></tr>";
    $Row = mysqli_fetch_assoc($QueryResult);
} while ($Row);
mysqli_free_result($QueryResult);
mysqli_close($DBConnect);
?>              

It only returns one row.. how can I return all entries?

1
  • Why are you using mysqli_fetch_row() in one place and mysqli_fetch_assoc() in another? It looks like you should be using mysqli_fetch_row() in the second case as well (inside of the do loop). Commented Dec 4, 2009 at 17:00

2 Answers 2

3

Have you tried

while ($Row = mysqli_fetch_row($QueryResult))

Description here

or

while ($Row = mysqli_fetch_array($QueryResult, MYSQL_ASSOC))

Description here

Hope this helps.

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

Comments

0

In your code, only the first time you call mysqli_fetch_row, which makes an $Row an indexed array. This is why you see output when you access the content of $Row with an index ($Row[0], $Row[1], etc..). Afterwards, you mysqli_fetch_assoc which turns $Row in an associative array, thus accessing $Row with an index for your output doesn't work anymore.

Replace your do ... while loop by the first while loop aforloney suggested.

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.