Jump to content

Recommended Posts

How to re order records after a delete or move?

 

I have table of navigational items. lets say under "about us" i have 5 sub links and i order them by a field called theorder. How can a re order them properly if one is deleted?  orders are 1,2,3,4,5 and if i delete the record that is 3 then the order is 1,2,4,5 but i want it to now become 1,2,3,4.  How do i do this properly?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/213289-new-order-after-delete/
Share on other sites

yeah.  how was this comment helpful at all?  Sorry to the almighty for not knowing all the rules or even finding the answer already posted (where?).

 

If i dont want to order the results with mysql by a field which contains the order show me how to do it in php then!

 

 

yes i could do $i ++ during the loop of the records but i want to keep the sort order which may change in tact. like if im listing 5 links under a parent link and i have defined them in the order that i want using a field but i remove say the record that is sort order #3 then i need to change so sort order for the links becomes 1,2,3,4 not 1,2,3,5 .  How will a counter or even php know what order i want these links in?  what if i add a link or change the order of them down the road.  Dont i have to do it via mysql with an ORDER BY satement not with php as php will not know what order i want them in?

I apologize for posting in different boards (didn't know if this question would be best answered in mysql or php so i posted in both).

 

I posted in both prior to Fenway's offer to move so its not like i didnt take Fenway up on the offer and went out of my way to do it anyway.

 

I am still looking for an answer to this scenario if anyone is interested in posting.

Guest
This topic is now 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.