Jump to content

MySQL Re-Ordering


ibinod

Recommended Posts

I have a menu table which contains column like this

   

id

       

name

       

link

       

position

       

   

1

       

Home

       

home.php

       

1

       

   

2

       

About

       

about.php

       

2

       

   

3

       

Contact

       

contact.php

       

3

       

   

4

       

Faq

       

faq.php

       

4

       

   

5

       

Message

       

msg.php

       

5

       

   

6

       

Downloads

       

down.php

       

6

       

 

now let's say i want to change the position column value to 2 of id column that has id 1 and at the same time i want to change the position column value to 1 which has position value 1

can you pls suggest me how do i do this using php

 

using mysql i was able to do like this but pls suggest me a better way to do it using php

UPDATE menu SET position = 1 WHERE id = 2;
UPDATE menu SET position = 2 WHERE position = 1;

 

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.