mysql fetch array if no results display message(如果没有结果显示消息,mysql fetch array)
本文介绍了如果没有结果显示消息,mysql fetch array的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试进行数据库调用以显示一条语句,如果没有返回结果,则表示没有找到结果.
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:-
$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 语句.
This needs an IF statement.
$rows = mysql_fetch_array($getFixtures);
if(count($rows))
{
while ($fixtureData = $rows)
...
}
else
{
echo 'No results found';
}
这篇关于如果没有结果显示消息,mysql fetch array的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:如果没有结果显示消息,mysql fetch array
猜你喜欢
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- Laravel 仓库 2022-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01