Re: ORDER BY is not sorting

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

 



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

[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux