tags:

views:

103

answers:

1

Hello,

I am currently having an issue where MySQL is only displaying 1 of my 3 rows in a dynamic Temporary Table ive created in a PHP page. I can confirm how many rows the TmpTable has via:

$numrows = mysqli_num_rows($doResults);

// returns 3

But when I do my while($rows=mysqli_fetch_array($doResults)){ }

Only 1 of the 3 rows are returned/displayed. ( The one row is returned correctly with all fields requested )

Has anyone had any issues with some sort of Caching, etc ... ?

-L

A: 

mysqli_fetch_array() returns the next record in the result set, only one record. The name of your variable $rows suggests that you expect otherwise.

Try something like

error_reporting(E_ALL); // only for debugging
ini_set('display_errors', 1); // only for debugging

$numrows = mysqli_num_rows($doResults);
echo '<pre>debug: $numrows=', $numrows, "</pre>\n";
$dbgcRow = 0;
while($row=mysqli_fetch_array($doResults)) {
  // row counter / number of the current record
  echo '<pre>debug: $dbgcRow=', ++$dbgcRow, "</pre>\n";
  // print the values of the current record
  echo htmlentities(join(',', $row)), "<br />\n";
}
VolkerK
Thank you for your quick reply ... I ended up figuring out my issue. I had a second while loop inside my while loop that was causing it to exit after displaying 1 row. Changed to for loop and works great now!Thanks again and God Bless-L