Re: Help: do ... while, reverse data query

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

 




you can do it at sql level by using ORDER BY ... DESC like:


SELECT * FROM categories
WHERE cat_id = '$cat'
ORDER BY cat_id DESC

and then proceed the returned recordset in 'normal' way (order)

--

Douglas Freake wrote:

Hi there,

I need to do a loop where the mysql query starts
at the bottom and goes up, as if the data was in
reverse order. This is for building a category/
sub_category menu.

Data structure: (cat_id, cat_sub, cat_name)

sample routine:

    do {
        $sql = "SELECT * FROM categories WHERE cat_id = '$cat'";
        $go = mysql_num_rows($sql_result);
        $cat = $row["cat_sub"];
        $cat_id = $row["cat_id"];
    } while ( $go == 1);

Any ideas how to to start a the end of the database?
Thanks for your help!

Doug


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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux