mysql fetch array if no results display message

后端 未结 2 995
走了就别回头了
走了就别回头了 2020-12-12 07:39

I am trying to get a database call to show a statement saying no results found if there are no results returned.

How would I go about doing this to my code:-

相关标签:
2条回答
  • 2020-12-12 07:53
    if ( ! mysql_num_rows($getFixtures)) {
       echo 'No results found.';
    } else {
      ...
    }
    
    0 讨论(0)
  • 2020-12-12 07:59

    This needs an IF statement.

    $rows = mysql_fetch_array($getFixtures);
    if(count($rows))
    {
        while ($fixtureData = $rows)
        ...
    }
    else
    {
        echo 'No results found';
    }
    
    0 讨论(0)
提交回复
热议问题