MySqli 没有输出我的查询结果时遇到问题。
$cxn=mysqli_connect($host,$user,$pw,$dbname) or die("Error connecting to server");
if(!$cxn=mysqli_connect($host,$user,$pw,$dbname)){
$message=mysqli_error($cxn);
echo $message;
die();
}
$query= "SELECT * from merchantinfo WHERE industry='Retail'";
$result=mysqli_query($cxn,$query) or die("Could not execute the query");
$row=mysqli_fetch_assoc($result);
while($row = mysqli_fetch_assoc($result))
{
extract($row);
echo "$INDUSTRY: $NAME<br/>";
}
这是我目前正在使用的表。(merchantinfo)
MerchantID INDUSTRY NAME DESCRIPTION
1 Dining Burger King Whopper,Whoppers galore!
2 Retail ZARA A large clothing retailer
3 Aviation Virgin Airlines Lolwut
我目前在查询后得到一个完全空白的页面,但我似乎无法找出问题所在。我尝试将 $query 和 while 循环中的“行业”更改为所有大写字母以匹配表中的大写字母,我还尝试将它们全部用于小写字母。然而,我仍然得到一个空白页作为输出。
我也尝试将 $query 更改为
$query="SELECT * FROM merchantinfo";
产生结果:
Retail:ZARA
Aviation:Virgin Airlines
如果有人能指出代码中的错误或指出我正确的方向,我将不胜感激
谢谢!