views:

57

answers:

3
<?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?

+3  A: 

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.

Anthony Forloney
+1: That's what I was going to suggest.
R. Bemrose
A: 

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.

catchmeifyoutry
A: 

Thaks so much!! It's working now!

Christina