SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Small script change help needed.

    I got this code:
    PHP Code:
    $sql "SELECT * FROM cmt_table WHERE cmtnews_id = '$news_id' AND cmt_checked = '1' ORDER BY cmt_date DESC";
    $results3 mysql_query($sql)
      or die(
    mysql_error());
      echo 
    "</table><table width=100% height=1 cellspacing=0 cellpadding=2 vspace=0 hspace=0><tr><td valign=top width=100% bgcolor=#EEEEEE>";
    while (
    $row3 mysql_fetch_array($results3)) {
      
    extract($row3);
      echo 
    "<font face=\"Verdana,Arial\" size=\"1\" color=\"#000000\"><b>$cmt_poster$cmt_country</b><br>$cmt_txt</font><br><br>";

    I want the possibility, that if there are no records in the database (using the sql), it will show a link called "Be the first to comment this news" , and if there are records in the database, there will be a link called "Comment this news" and the records in the db. Is that possible? What kind of code do I use for that?

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Try this:
    PHP Code:
     $sql "SELECT * FROM cmt_table WHERE cmtnews_id = '$news_id' AND cmt_checked = '1' ORDER BY cmt_date DESC";
    $results3 mysql_query($sql)
      or die(
    mysql_error());
      echo 
    "</table><table width=100% height=1 cellspacing=0 cellpadding=2 vspace=0 hspace=0><tr><td valign=top width=100% bgcolor=#EEEEEE>";
    if (
    mysql_num_rows($results3)>0) {
        while (
    $row3 mysql_fetch_array($results3)) {
          
    extract($row3);
          echo 
    "<font face=\"Verdana,Arial\" size=\"1\" color=\"#000000\"><b>$cmt_poster$cmt_country</b><br>$cmt_txt</font><br><br>";
        } 
    }else{
        echo 
    "Be the first to comment this news";

    Saul

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it worked thanks a lot for your help.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •