For Programmers: Free Programming Magazines  


Home > Archive > PHP on Windows > August 2007 > Re: [PHP-WIN] Solved - Re: [PHP-WIN] ORDER BY is not sorting









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-WIN] Solved - Re: [PHP-WIN] ORDER BY is not sorting
Armando

2007-08-03, 7:04 pm

I've seen this issue before as well.. if you want to keep the
$table_name variable in there in order to maintain dynamics, try
escaping first and it should work fine. Your modified query would look
like this:

$result = mysql_query("SELECT * FROM ". $table_name ." ORDER BY rowID
DESC");

Cheers.

Armando

Mark Abrams wrote:
> Thank you all. Problem solved.
>
> Gustav, I followed your recomendation and changed the table name var to the
> actual table name and my problem is solved. Perpaps something is lost in the
> interperter when PHP passes the code.
>
> It has been this group that helps make working with PHP fun.
>
> "Gustav Wiberg" <gustav@hmn.se> wrote in message
> news:6E.E1.12911.71320B64@pb1.pair.com...
> Hi!
>
> I can't see anything with your code either. Mysql_fetch_array should work
> fine yes. No indexes are needed to sort fields, but are recommended for
> speeding up the process :-)
>
> How does the table users look like? (Please send a link to a screenshot or
> something like that)
>
> Sometimes I have noticed that PHP isn't that good of getting right results
> when using $variable inside ""-chars
>
>
> You could try doing this:
>
> $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 />'
>
>
> There might be some issues regarding permissons of MySQL. Have you tried
> doing another sql-select statement on another table?
>
> Best regards
> /Gustav Wiberg
>
>
>
>
> -----Original Message-----
> From: Mark Abrams [mailto:mark@hospitalsystemsgroup.com]
> Sent: Wednesday, August 01, 2007 12:50 AM
> To: php-windows@lists.php.net
> Subject: Re: [PHP-WIN] ORDER BY is not sorting
>
> 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...
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com