MySQL的获取数组,如果没有结果的消息显示 [英] mysql fetch array if no results display message
本文介绍了MySQL的获取数组,如果没有结果的消息显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获得一个数据库调用,显示一个声明,称没有结果发现如果没有返回结果。
I am trying to get a database call to show a statement saying no results found if there are no results returned.
我怎么会去这样做是为了我的code: -
How would I go about doing this to my code:-
$getFixtures = mysql_query("SELECT ht.name AS hometeam_name, homescore, awayscore, at.name AS awayteam_name, time, date, week, comp.competition AS comp_name, se.name AS season_name
FROM fixture
JOIN team ht
ON ht.id = fixture.hometeam
JOIN team at
ON at.id = fixture.awayteam
JOIN competition comp
ON comp.id = fixture.competition
JOIN season se
ON se.id = fixture.season
WHERE se.name = '$season' AND comp.competition = '$competitiontitle' AND date >= '$today' AND at.name = '$teamName' OR ht.name = '$teamName' AND se.name = '$season' AND comp.competition = '$competitiontitle' AND date >= '$today'
ORDER BY date ASC
");
while ($fixtureData = mysql_fetch_array($getFixtures))
{
$hfixteamlink = strtolower(str_replace(" ","-",$fixtureData['hometeam_name']));
$afixteamlink = strtolower(str_replace(" ","-",$fixtureData['awayteam_name']));
$date = date("d/m/Y", strtotime($fixtureData['date']));
?>
在此先感谢
理查德
推荐答案
这需要一个IF语句。
$rows = mysql_fetch_array($getFixtures);
if(count($rows))
{
while ($fixtureData = $rows)
...
}
else
{
echo 'No results found';
}
这篇关于MySQL的获取数组,如果没有结果的消息显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文