Re: Re: mysql results, arrays, and for loops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yes, thanks to all that assisted. I got it working like a charm!

~Philip

On Jun 11, 2004, at 9:30 AM, Torsten Roehr wrote:

"Philip Thompson" <prthomp@xxxxxxxx> wrote in message
news:539DCBEC-BBB2-11D8-8631-000393C795C4@xxxxxxxxxxx
Hi all!

I am using a select statement to obtain all the dates whenever someone
submitted a problem in a database. Well, I want to get the result
(which could be multiple dates) and then print that in a table format
with some other information on a webpage. So I want to use a FOR loops
and go through each of the dates and dynamically create a table.

My question is: how do I store the results of the select query? Would I
want to store them in an array, and then just parse through each
element of the array, and what is the syntax for that? Or is there a
better way?

You can loop through your query results in this way:


$result = mysql_query('SELECT * FROM table');

while ($row = mysql_fetch_assoc($result)) {

// row is now the current record set as an associative array, keys
represent the field names
// do what you want with row, e.g. print a field value from column date
echo $row['date'];
}


Is this what you are looking for?

Regards,
Torsten Roehr

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux