RE: [PHP] help with "ORDER BY" query
| From: | Carlo Razzeto | Date: | Fri, 29 Jul 2005 14:30:16 +0000 |
| Subject: | RE: [PHP] help with "ORDER BY" query | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-219602@lists.php.net to get a copy of this message | ||
The following line:
$query_r = mysql_fetch_array($query)
Will pop off the first result from the query, you can avoid this problem by using mysql_num_rows
instead:
if( mysql_num_rows( $query ) > 0 ).......
Carlo Razzeto
Programmer
Mortgage Information Services
Phone: (216) 514-1025 ex. 1212
-----Original Message-----
From: Jesús Alain Rodríguez Santos [mailto:wmaster@cfg.jovenclub.cu]
Sent: Friday, July 29, 2005 11:00 AM
To: php-general@lists.php.net
Subject: [PHP] help with "ORDER BY" query
I have a query:
$query = mysql_query("SELECT event FROM table WHERE month = 'x' ORDER BY
day ASC");
I have all days of the month insert in day field: 1, 2, 3, 4, 5 ...
when I print the query:
if ($query_r = mysql_fetch_array($query)) {
do {
echo "<td
width='8%'>".$query_r['event']."</td>\n";
} while ($query_r = mysql_fetch_array($query));
echo "</tr> \n";
} else {
echo "No se encontraron registros";
}
It print all result of the query, less day 1
What it's the problem
--
Este mensaje ha sido analizado por MailScanner
en busca de virus y otros contenidos peligrosos,
y se considera que está limpio.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Disclaimer: This message (including any attachments) contains confidential information intended for
a specific individual and purpose, and is protected by law. If you are not the intended recipient,
you should delete this message. Any disclosure, copying, or distribution of this message, or the
taking of any action based on it, is strictly prohibited.