Hi,
> >>> The command in PHP is: > >>> > >>> $query="SELECT id,first_name,last_name FROM Player ORDER BY id"; > >>> $players=mysql_query($query); > >>> > >>> When issued from the mysql prompt, order is fine, but when > >>> called from php I'm getting that strange order: > >>> > >>> 1, 10, 11, 12, etc... > >>> > >>> Steve Cochran > >>> > >> Then the problem is in your php code. Mysql will certainly return > >> the rows ordered the same way to both the mysql client and to > >> php. If php is showing a different order, then it must be > >> something your php code is doing. If you post the code which > >> displays the results, I'm sure someone could point out the > >> problem, though that really belongs on a php list. > >> Michael > >> > > > > I had this same problem a while back, and while I'm probably making > > the same mistakes you are but have no idea what they are, I solved > > it by using ZEROFILL on the field I was sorting. So that PHP was > > seeing 0001, 0002, 0003... > > > > Worked for me, although from some of the replies I'm wondering if > > that wasn't the best way to do it. :/ > > Well, since I wasn't the only person to have this problem, I'll post > this here in case someone has the answer. My php code is: > > $query="SELECT id,first_name,last_name FROM Player ORDER BY id"; > $players=mysql_query($query); > $numPlayers=mysql_numrows($players); > for ($i=0, $i < $numPlayers; $i++) > { > $label = mysql_result($players,$i,'id'); > echo "$label<br>" > } Try with mysql_fetch_array > > And that generates an order like it was doing a string comparison. > I'm just iterating over the rows in the result in order, so not sure > what would be applying another sort. or it's likely that mysql_result retrieve an array of rows (well-ordered), but fetch it by using a string for the index. -- Pooly Webzine Rock : http://www.w-fenec.org/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]