Announcement

Collapse
No announcement yet.

MySQL query to get latest threads

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

  • [CMS] MySQL query to get latest threads

    Can anyone please give me the start point for the PHP code for a query that returns the latest threads from a given forum or forum group? I can't seem to find much in the documentation on this. I know PHP/MySQL so if I had a template to start from I'd be able to get it in no time.

    Thanks.

  • #2
    Here is a query I use for displaying a custom forumdisplay. Replace $f with the correct forumid number.

    $sql = "
    SELECT threadid, title, postusername, lastpostid, replycount
    FROM thread
    WHERE forumid='$f'
    AND visible='1'
    ORDER BY lastpost DESC
    LIMIT 50;

    Comment


    • #3
      hi andy

      by code

      PHP Code:
      <?php 

      chdir
      (public_html/forums); 
      require_once(
      './global.php'); 

      $threads $db->query_read(
      SELECT title FROM " 
      TABLE_PREFIX "thread 
      ORDER by dateline DESC 
      LIMIT 0,5 
      "
      ); 
      while (
      $thread $db->fetch_array($threads)) 

      echo 
      $thread['title'] . "<br />"

      ?>
      I want to have a link with

      thank you
      Thailand Vbulletin |Thailand country radio

      Comment


      • #5
        How can the amount of preview text be increased?

        Comment


        • #6
          PHP Code:
          $threads $db->query_read("
          SELECT IF(LENGTH(`title`) > 200, CONCAT(LEFT(`title`, 150), '...'), `title`) AS teaser
          FROM " 
          TABLE_PREFIX "thread 
          ORDER by dateline.teaser DESC 
          LIMIT 0,5 
          "
          ); 
          Everything above 200 characters will get shortend to 150 then plus a '...' will be added.
          No private support, only PM me when I ask for it. Support in the forums only.

          Comment


          • #7
            Thank you so much Hartmut!! I will give this a shot. I have been racking my brain on this.. Thank you

            I am trying to create a recent threads or posts center widget for the cms. I want to show much of the posts though and not just the basics as the current widgets do.

            Comment

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