View Full Version : Organizing Articles Efficiently

03-05-2007, 03:55 AM
I'm creating a content management system for a client. It allows the client to post news very quickly as well as delete it. I'm trying to make a user friendly way to arrange the news.

When the client deletes news, it doesn't really delete the article (for reference) it just turns the row's field "show" to "0" I've now made a field "order" which will basically match the row id. Now the problem is if a field is deleted and the order is changed, it sometimes will not work because for example

row 1: title="hi" news="hi" order="1" show="1"
row 2: title="hi" news="hi" order="2" show="0" (deleted.)
row 3: title="hi" news="hi" order="3" show="1"

Now to make article "3" be above article "1", I was going to increase the order "1" to "2" and decrease the order "3" to "2" but then I'll have 3 rows with the order set to "2"

What is an efficient way to approach and correct this problem.

03-05-2007, 05:31 PM
News articles should be shown according to date. That's the most intuitive way.

To do what you want to do:

$sql = "SELECT * FROM news ORDER BY show DESC, `order` ASC";

03-05-2007, 07:31 PM
And of course sir, I know this. But is there a way to manipulate the order regardless of date, or should I just refresh the date o.0

03-05-2007, 07:32 PM
Hmm I think I got it, thanks. Great idea. I was just making things more difficult as always.:thumbsup: