Jump to content

Database Row Order


manels1111

Recommended Posts

Hey guys another quick question I'm using php to create 15 rows in my database using this code

 

mysql_query("INSERT INTO category (ID, cat_id, category) VALUES 
			('$ID','1', 'Blank'), 
			('$ID','2', 'Blank'),
			('$ID','3', 'Blank'),
			('$ID','4', 'Blank'),
			('$ID','5', 'Blank'),
			('$ID','6', 'Blank'),
			('$ID','7', 'Blank'),
			('$ID','8', 'Blank'),
			('$ID','9', 'Blank'),
			('$ID','10', 'Blank'),
			('$ID','11', 'Blank'),
			('$ID','12', 'Blank'),
			('$ID','13', 'Blank'),
			('$ID','14', 'Blank'),
			('$ID','15', 'Blank')") 
			or die(mysql_error());  

 

This code works fine except for some reason in my database its listed out of order.  In what I'm trying to accomplish I need to input and into my database in the order I layed out here.  Instead I got this in the table

 

ID cat_id category

7    15    blank

7    14    blank

7    13    blank

7    12    blank

7    11    blank

7    10    blank

7    9      blank

7    8      blank

7    7      blank

7    5      blank

7    4      blank

7    3      blank

7    2      blank

7    1      blank

7    6      blank

 

I really need to to display in order by the cat_id because when I loop through the array to create text boxes that users will use to update the database it has to be in order without a lot of work on my end.  I hope this makes sense.  Does anyone know why its not getting written to the database in the order it should be received from my php code.

 

Thanks in advance,

Link to comment
https://forums.phpfreaks.com/topic/161880-database-row-order/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.