display other text if there is no sql data to display

Discussion in 'PHP' started by subdivisions, Dec 10, 2009.

  1. #1
    sorry if i'm describing something wrong or ambiguously, i'm somewhat of a noob at php and mysql, i'm just trying to write a basic comment system for a website.

    if there is no mysql data to display (due to filters or empty rows), how would you display alternate text ("No comments")?

    thanks
     
    subdivisions, Dec 10, 2009 IP
  2. Hipto

    Hipto Peon

    Messages:
    939
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $getAll = mysql_query("SELECT * FROM `XXXXX`",$SERVER);
    if (mysql_num_rows($getAll) == 0) {
    echo '<tr><td colspan="3" align="center">Nothing found.</td></tr>';
    }
    else {
    while($data = mysql_fetch_array($getAll)) {
    echo
    }
     
    Hipto, Dec 10, 2009 IP