gpt4 book ai didi

php - mysql fetch array 如果没有结果显示消息

转载 作者:行者123 更新时间:2023-12-01 00:15:00 26 4
gpt4 key购买 nike

我正在尝试获取一个数据库调用以显示一条声明,如果没有返回任何结果,则说明没有找到任何结果。

我将如何对我的代码执行此操作:-

$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';
}

关于php - mysql fetch array 如果没有结果显示消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6200176/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com