Re: Display of fetched MySQL data?
| From: | Ryszard Hapka | Date: | Thu, 25 Mar 2004 13:04:05 +0000 |
| Subject: | Re: Display of fetched MySQL data? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-33642@lists.php.net to get a copy of this message | ||
Hi!
use foreach (www.php.net/foreach).
Ryszard
W. D. wrote:
Hi Folks, I am trying to display a list of retrieved records, but can't seem to figure out how to do this properly. Here is what I am aiming for: <? $result = mysql_query($SQLqry); $NumRows = mysql_num_rows($result); $NumFields = mysql_num_fields($result); // Loop through each row for ($RowIdx = 1; $RowIdx <= NumRows; $RowIdx++) { Echo "Record: ".($RowIdx + 1)."<BR>\n"; // Loop through the fields for ($FieldIdx = 1; $FieldIdx <= NumFields; $FieldIdx++) { // Display the fields and associated data /* What code goes here????? */ } } // End for ($RowIdx = 1; $RowIdx <= NumRows; $RowIdx++) ?> How do I properly display the fieldname and its associated data? I know that you can do something like this using foreach, but I wanted a generic routine where you don't necessarily know the fieldnames. Any hints? (Thanks if you do!) Start Here to Find It Fast!™ -> http://www.US-Webmasters.com/best-start-page/-- <?php $me = array( "name" => "Ryszard Hapka", "mobile" => "693 340 403", "GG_number" => "4765174", "url_page" => "www.hary.rnet.pl" ); ?>