Re: sort in while(list($vars) = mysql_fetch_row($result))

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

 



Verdon Vaillancourt wrote:
Hi,

I'm running into some sorting issues using a while(list($vars) = mysql_fetch_row($result)). I can provide more code if needed, but thought I would try this little bit first to see if I'm missing a fundamental concept and not a detail.

In a nutshell, I have a query first..
$result = mysql_query("select id, text, url, m_order from menu where level = 2 && active = 1 order by m_order");

.. the result of this query is sorted correctly by m_order


Then I pass it through this..
while(list($id, $text, $url, $m_order) = mysql_fetch_row($result)) {
  $out .= "$text - $m_order \n";
}
echo $out;

.. it is now no longer in the order it was in the query. In some results it is, in others it's not.

Looks ok from your example, however which column are you looking at for your ordering?

My first guess is that's you're looking at the 'text' column (before the -) in your output and not seeing that ordered... it's the second column you should look at since that's you're "order by" in the query.

Provide a short example of what you get when you run the query manually and what you get as the output where it doesn't match up.

--
Postgresql & php tutorials
http://www.designmagick.com/

--
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