Re: ORDER BY is not sorting
| From: | Dan Shirah | Date: | Tue, 31 Jul 2007 19:59:57 +0000 |
| Subject: | Re: ORDER BY is not sorting | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-28292@lists.php.net to get a copy of this message | ||
Well, it looks like you're trying to get your results in an array and run
the query all at the same time. Also, I believe you need to put the variable
in your SELECT statement inside of some single quotes.
Try something like this:
$query = "SELECT * FROM '$table_name' ORDER BY DESC";
$result = mysql_query($sql) or die(mysql_error());
Then you can take your $result variable and output the data, put it into a
loop, or select specific records.
Hope that helps.
On 7/31/07, Mark Abrams <mark@hospitalsystemsgroup.com> wrote:
>
> 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
>
>