Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Databases w/PHP, how to cycle through entries?

Status
Not open for further replies.

natwod

Programmer
Nov 21, 2002
41
US
I have a question about displaying database info using PHP. I am trying to display data from a database one entry at a time, but I am not able to get it to move on to the next Row. I’m not sure, but there may be a problem with my While statement as well.

This is a sample of what I have currently. I have already set up a database connection with the variable $connectionRS. The output for this code is only one row; I want it to display all of the rows (entries) in my database file.

<table>
<?php

Do {
$itemLastName = odbc_result($connectionRS, &quot;LastName&quot;);
$itemFirstName = odbc_result($connectionRS, &quot;FirstName&quot;);

echo &quot;<tr> <td>{$itemLastName}</td>&quot;;
echo &quot;<td>{$itemFirstName}</td></tr>&quot;;

} While (odbc_next_result($connectionRS));

?>
</table>
Note: I also tried copying the odbc_next_result…. statement up inside the Do braces to see if that would “move the playhead” down to the next row; didn’t work.

Thanks a ton for any comments!

Natwad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top