Displaying articles in a particular order with PHP and MySQL
Posted 16 May 2006 - 03:06 AM
Basically I'm creating a PHP/MySQL site from the ground up. One because I want to understand everything that is going on with the code so I will be able to work on it. I guess I'm making a lite CMS.
I have a nice template made, a "backend" so I can write/edit/delete "articles". And many other useful features created.
But what I can't figure out, is how to make each article appear in a particular order.
I don't know if this is something that is done purely with MySQL or what? I'm not talking about sorting acsending or decending, or by the date. I need to assign a order to the articles, and when I decide that another article should be shown up higher on the list, how will the order of the other articles be updated?
I'm not looking for someone to write me the code. But I can't figure out what keywords to Google with to find the answer for myself.
Any insight would be greatly appreciated.
Posted 16 May 2006 - 05:16 AM
The only other way to do this, that I can think of, is to place them in an order by reference number, then when you add a new article, your script adds +1 to each reference number - bumping each one down in the list of ordered articles [img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /] .
Posted 16 May 2006 - 01:54 PM
Then when I add or edit another article and want it to appear in let's say the 5th slot, I have a function increment each "appearance number" in the table greater than 5?
Then have a function that does the exact opposite when that article is deleted?
Then when my script displays the article, it sorts them ascending using the numbers from my new "appearance" colum?
BTW I'm really thankful for your input.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users