Re: ORDER BY is not sorting
| From: | Mark Abrams | Date: | Tue, 31 Jul 2007 22:49:56 +0000 |
| Subject: | Re: ORDER BY is not sorting | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-28295@lists.php.net to get a copy of this message | ||
Is mysql_fetch_array the proper function to access sorted data? The
problem is consistent on my test server and my ISPs mySQL DB.
rowID is the primary key. Do I need to have an index attribute on a field I
want to sort?
<tg-php@gryffyndevelopment.com> wrote in message
news:20070731203155.CEE1819504F@spaceymail-a3.g.dreamhost.com...
>I can't really see anything wrong with what you have there. It shouldn't
>matter that your SQL is inside the query function, although I like to build
>the query in a variable outside the query function, but either way it
>should work.
>
> And you're obviously getting data and not an error, right?
>
> What happens if you leave the "DESC" off? Does it come back 4, 3, 2, 1?
> or still 1, 2, 3, 4?
>
> You might try displaying more data from the result set to see if there's
> some other issue.
>
> And have you tested the SQL statement just using MySQL via command line,
> phpMyAdmin, WinSQL, Navicat, or something like that?
>
> -TG
>
> = = = Original message = = =
>
> Sorry, this seams very trivial but I can not sort the result set for any
> field. What am I doing wrong?
>
>
> php & mySQL 5
>
>
> <?php
>
> ...
>
> $table_name ='users';
>
> // Select records
> $result = mysql_query("SELECT * FROM $table_name ORDER BY rowID DESC");
>
>
> // Loop through the record set
> while($row = mysql_fetch_array($result))
> print 'rowID =' .$row['rowID']. '<br />'
>
>
> ?>
>
> 1
> 2
> 3
> 4
>
>
> TIA
> Mark
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> ___________________________________________________________
> Sent by ePrompter, the premier email notification software.
> Free download at http://www.ePrompter.com.