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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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