On Thu, 2 Sep 2004, Torsten Roehr wrote:

> > I think I need just a little push in the right
> > direction. After I send the above SELECT command, how
> > do I get the result to appear on a web page?
> 
> mysql_query() will return a result set. There are
> different functions to extract the rows from it. I would
> recommend mysql_fetch_assoc() - it returns an associative
> array of the current row/record set where the field names
> of your table become the keys of the array. So if you
> select firstname, lastname you will get an array like
> this:
> 
> array('firstname' => 'My firstname', 'lastname' => 'My lastname')
> 
> Just loop through your result set to output/process the data. Try this:
> 
> $result = mysql_query('SELECT firstname, lastname FROM table');
> 
> while ($row = mysql_fetch_assoc($result)) {
> 
>     echo $row['firstname'] . ' ' . $row['lastname'];
> }
> 

I want to display the sorted database. Which makes more
sense: sorting the database table itself (either by address
or by name), or sorting the array?

Thanks.

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

Reply via email to