Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Apr 2004
    Location
    Philadelphia
    Posts
    241
    Thanks
    2
    Thanked 5 Times in 5 Posts

    Organizing Articles Efficiently

    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.

  • #2
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    News articles should be shown according to date. That's the most intuitive way.

    To do what you want to do:

    PHP Code:
    $sql "SELECT * FROM news ORDER BY show DESC, `order` ASC"

  • #3
    Regular Coder
    Join Date
    Apr 2004
    Location
    Philadelphia
    Posts
    241
    Thanks
    2
    Thanked 5 Times in 5 Posts
    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

  • #4
    Regular Coder
    Join Date
    Apr 2004
    Location
    Philadelphia
    Posts
    241
    Thanks
    2
    Thanked 5 Times in 5 Posts
    Hmm I think I got it, thanks. Great idea. I was just making things more difficult as always.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •