Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP comment box question

Options
  • 04-04-2006 6:59pm
    #1
    Registered Users Posts: 3,165 ✭✭✭


    Ok, so I've a comment box in my website, and I'd like to limit the amount of comments the page shows, because if there's too many, it'll just **** up the site, I've tried many variations of installing a counter variable into the loop, but to no avail, so here's the PHP code:
    <?php
    $dbh=mysql_connect ("localhost", "blahblah", "blahbalh") or die ('I cannot connect to the database because: ' . mysql_error());
    mysql_select_db ("blahblah");

    $result = mysql_query("SELECT * FROM comments ORDER BY id DESC");
    while($r = mysql_fetch_array($result))
    {
    $comment=$r["comment"];
    $by=$r["by"];

    echo "<strong>message:</strong><br>$comment<br><strong>Comment by: </strong>$by<br><br>";
    }

    mysql_close();
    ?>


Comments

  • Registered Users Posts: 19,396 ✭✭✭✭Karoma


    ORDER BY id DESC LIMIT... ?


  • Registered Users Posts: 3,165 ✭✭✭DEmeant0r


    hrmm I'll try that, hope if works... [edit] lol ok it worked, didn't know there was such an easy solution, thanks![/edit]


Advertisement