[英]Setting Multiple Variables with php and MySQL
So I have a code I want to use 所以我有一个要使用的代码
mysql_select_db("website", $con);
$result=mysql_query("SELECT * FROM characters where online='1'");
while ($row=
mysql_fetch_array($result))
{
echo $row['name'];
}
if ($row['race'] == "1");
{
echo '<img src="img/8-0.gif" />';
}
if ($row['class'] == "3");
{
echo '<img src="img/3.gif" ?>';
}
mysql_close($con);
?>
Now I only wanted the two images to show if the online field was 1, but they show no matter what. 现在,我只希望显示在线域是否为1的两个图像,但是无论如何它们都显示。 Does anyone know how I can fix this?
有谁知道我该如何解决? Thanks.
谢谢。
For the sake of the argument: 为了论证:
mysql_select_db("website", $con);
$result=mysql_query("SELECT * FROM characters where online='1'");
while ($row= mysql_fetch_array($result))
{
echo $row['name'];
//} This bracket would immediately close your query processing and only display the last images. Or is that the desired behaviour?
if($row['isOnline'] == '1') { //Makes sure, that 'isOnline' is set before displaying.
if ($row['race'] == "1");
{
echo '<img src="img/8-0.gif" />';
}
if ($row['class'] == "3");
{
echo '<img src="img/3.gif" ?>';
}
}
} //This bracket closes the actual query result handling
mysql_close($con);
?>
if ($row['race'] == "1" AND $row['online'] == 1);
{
echo '<img src="img/8-0.gif" />';
}
if ($row['class'] == "3" AND $row['online'] == 1);
{
echo '<img src="img/3.gif" ?>';
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.