Announcement

Collapse
No announcement yet.

How to sticky news with PHP if statement?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to sticky news with PHP if statement?

    Hey guys -

    I have a custom news submission service on my site and I'm trying to give it the ability to stick news. I've created the database field and added the field to all the templates.

    I have a drop down menue with the options "Yes" and "No"

    Basically, if a staff member selects "Yes" the item will remain atop of the news on the page. However, I just can't think of how to accomplish that with an else statement.

    Attached is the text of my php coding that I use to retrieve news from the database. I know it's not the cleanest of coding, but it's definitely neat.

    If anyone could look at it and give suggestions on how to accomplish this... I would really, really appreciate it!

    Thank you very much for your time!

    Sincerely,
    Andrew
    Attached Files
    Andrew Tatum
    FinHeaven & Co - Get Splashed With FinForMation
    The FinHeaven & Co Forums - Your Opinion, Your Team, Speak It Here

  • #2
    I'm not sure if this will work but make a new field in your "news" table named "stickied", varchar, Length: 3.

    Now edit your drop down menu so if you select "yes" it'll put "yes" in the stickied cell.

    Then write something like
    Code:
    if ($result['stickied'] == "yes") 
    {
     echo "display the stickied news";
    } else {
     echo "display nonstickied news";
    }

    Comment


    • #3
      Thanks for the reply, but for some reason that's not working out. It just displays all the news listed.

      Any other ideas?
      Andrew Tatum
      FinHeaven & Co - Get Splashed With FinForMation
      The FinHeaven & Co Forums - Your Opinion, Your Team, Speak It Here

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...
      X