RE: [PHP] php and mysql

From: Date: Mon, 23 Oct 2000 08:36:28 +0000
Subject: RE: [PHP] php and mysql
Groups: php.general 
Request: Send a blank email to php-general+get-21745@lists.php.net to get a copy of this message
oopps,... sorry .. not id int(0) - an intergrer of 0 digits zero in this example is 3 id int(3) - an intergrer of 3 digits :-)) -----Original Message----- From: Maxim Maletsky Sent: Monday, October 23, 2000 5:26 PM To: 'David Robley'; Scott Mebberson; Scott Mebberson; php-general@lists.php.net Subject: RE: [PHP] php and mysql What I think is that you field is something like varchar (whatever) if that field is your primary key you should make sure it looks something like this: id int(0) - an intergrer of 0 digits unsigned zerofill DEFAULT '000' -- default is 000 wchich means that every id is something like 001, 002, 003 NOT NULL auto_increment, - automaticly increases by one. in this case it won't sort your field alphabeticly. Just make sure it has a default value. -----Original Message----- From: David Robley [mailto:huntsman@hermes.nisu.flinders.edu.au] Sent: Monday, October 23, 2000 5:10 PM To: Scott Mebberson; Scott Mebberson; php-general@lists.php.net Subject: Re: [PHP] php and mysql On Mon, 23 Oct 2000, Scott Mebberson wrote: > Hi guys, > > I have a small problem and wonder if anyone has had the same problem. > > I am using MySQL and PHP for this application. I am retrieving some data > from the MySQL database. I am using SELECT and then ORDER BY. I am ordering > it by the content in a feild called elementID which contains numbers (1, 2, > 3, 4, 5, 6, 7, 8, 9, 10, 11). But when I extract it, MySQL is ordering it > like Windows Explorer orders files -- 1, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9 -- > This was cool though, I changed it to be 01, 02 ,03 ,etc and it all work. > The only thing is though, I was using a php loop to extract the files and > the loop could only understand the 1, 2, 3, 4 numbering system and not the > 01, 02, 03 > > So I am a little screwed. Anybody have a working around for this. Check the field type - it sounds like it is a string type field (var or varchar), which would sort in that sequence. You need it to be an numeric type field for the sort to work correctly. -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#21745) next »