[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-windows
Subject:    RE: [PHP-WIN] ORDER BY is not sorting
From:       "Luis Moreira (ESI-GSQP)" <luis.moreira () esi ! pt>
Date:       2007-08-01 10:35:25
Message-ID: 00d201c7d427$ac918720$05b49560$%moreira () esi ! pt
[Download RAW message or body]

Just one thought :

The code itself, as shown, looks good, but is PHP getting what WE see ?
Meaning, try to
1) set a string with the SQL query you want
2) check the string before applying it

Maybe, just maybe, you are getting a broken string, and the "order" part is
missing, thus not being applied...


Luis

-----Original Message-----
From: M. Sokolewicz [mailto:tularis@php.net] 
Sent: quarta-feira, 1 de Agosto de 2007 11:24
To: Gustav Wiberg
Cc: 'Mark Abrams'; 'php-windows@lists.php.net'
Subject: Re: [PHP-WIN] ORDER BY is not sorting

Gustav Wiberg wrote:
> 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
what do you mean by that??? You mean PHP is having trouble getting 
'right results' from a mysql database if _somewhere_ in the code there's 
an interpolated string? Sounds a bit iffy to me...

- Tul

> 
> 
> 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...
>> 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. 
> 

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

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic