Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Display of fetched MySQL data?
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!(TM) ->
http://www.US-Webmasters.com/best-start-page/

Report this thread to moderator Post Follow-up to this message
Old Post
W. D.
03-27-04 04:13 AM


Re: Display of fetched MySQL data?
W. D. wrote:

> 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!)
>

Check out the top example on this page:
http://www.php.net/manual/en/functi...fetch-array.php

And to get the field name itself:
http://www.php.net/manual/en/functi...-field-name.php

Albe

--
http://www.ninja.up.ac.za

Report this thread to moderator Post Follow-up to this message
Old Post
.:Ninja
03-27-04 04:13 AM


Re: Display of fetched MySQL data?
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!)
>
u also need to fetch the results. See the php mysql manual
part for more info.
Mart

Report this thread to moderator Post Follow-up to this message
Old Post
Mart
03-29-04 06:30 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Language archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:46 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.