On Thu, 2 Sep 2004, Torsten Roehr wrote:
>
> 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'];
> }
Well, I have this:
$result=mysql_query('SELECT * FROM $table ORDER BY surname, street, housenumber ASC');
while ($row=mysql_fetch_assoc($result))
{
echo $row['surname'].' '.$row['firstname'].' '.$row['housenumber'].'
'.$row['street'];
}
and I get "Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result
resource in /home/.fanny/pjh/4seasonsatmapleton.org/4sam/directory/showForm-mod.php on
line 26"
Line 26 is the while statement.
????
Thanks.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php