RE: help with "ORDER BY" query

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

 



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@xxxxxxxxxxxxxxxx] 
Sent: Friday, July 29, 2005 11:00 AM
To: php-general@xxxxxxxxxxxxx
Subject:  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.

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux