select from mysql code help

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

    select from mysql code help

    hello all
    i am trying to show last thread at my index
    i try that but it dosent work

    $lastt=$db->get_row("SELECT title FROM b_threads ORDER BY id DESC LIMIT 0,1");

    print "- Last Thread : <b>".$lastt."</b><br/>";

    and i want to link it to the thread
    THANKS

    #2
    It luks ok bt it also luks like im usin a database class so except we knw d content of d get_row method we cant help much

    Comment


      #3
      The syntax is exactly what you need. You can even choose to drop the limit, since you aren't looping through the query.

      Ok. From what I see, if you use the same structure as me, then that is the threads table NOT the replies to the thread. So I think making it

      select reply_text FROM replies_table WHERE thread = thread_id/name ORDER BY id/date DESC

      Fill in required fields and it should work. "/" signifies an alternative depending on how you structured your db. Therefore, if you recorded dates of replies/posts you can use that in your order, though I'd works just as well.

      Hope this helps.

      Added after 6 minutes:

      And oh, for the link, you will have to structure it based on your site's already existing method.

      If you display posts chronologically, then you will need to get the total number of posts in a given thread, divide it by your posts per page limit and find the last page of the thread then creat a hyperlink Including the page variable however it is implemented.

      Added after 7 minutes:

      Lol. I think I was digressing a little bit. I just noticed that you actually just wanted the thread, not the replies.

      Well drop the limit. Its perfectly okay though. Find out how the links to threads are made on the site and craft it like that.
      Last edited by frostymarvelous; 09.12.10, 18:03.
      Perfection comes at a cost



      I accept liberty!

      Comment


        #4
        i think you are using a similar class like i do,

        you should try this:

        PHP Code:
        $q $db->select("SELECT title FROM b_threads ORDER BY id DESC LIMIT 0,1");
        $lastt=$db->get_row($q'MYSQL_ASSOC');
        print 
        "- Last Thread : <b>".$lastt['title']."</b><br/>"
        Advertise your mobile site for FREE with AdTwirl

        Comment

        Working...
        X