Random news links

I asked this before, forgot it, and now have the same question again from someone whose site I'm maintaining. A list of random links to older news items. Same idea as random images, but now for news posts. I can't do it myself, but perhaps there is someone who could modify the printLatestNews() function into printRandomNews() to create a list of lets say three links?

Comments

  • acrylian Administrator, Developer
    You can do that with a quite simple mysql query:
    `$randomnews = query_full_array( "SELECT titlelink FROM ".prefix('news')." ORDER BY RAND() LIMIT 3")`
    Then use the object model with the result array to print the actual stuff you need.
  • dps Member
    Well! I want select only news from a given category, like "tip of the day", I must write a clause "WHERE ...". May you help me?
  • acrylian Administrator, Developer
    No, categories are stored in the table `news_categories` and the assigment within `news2cat`. Use the object model to get articles from a category. Please see the documentation.
Sign In or Register to comment.