php。数据库的值是0和1,如果数据库的值是1,就显示“欢迎登陆“,如果是0就什么都不显示,求一段代码。变量为 [$xml->dl] ,我写的是:
<?php
if [$xml->dl]==1 {
?>
欢迎登陆
<?php }?>
----------------------------------------
不知道有没有问题,请给段代码
有没有大神啊?
$con=mysql_connect('localhost','root','');//数据库信息
mysql_select_db('shop');//数据库名
mysql_query("set names utf8");//设置字符集编码
$sql="select goods_name,goods_number,shop_price from goods";//查询语句
$res=mysql_query($sql);//执行查询
while($row=mysql_fetch_assoc($res)){
$rows[]=$row;//接受结果集
}
//遍历数组
foreach($rows as $key=>$v){
echo $v['goods_name']."---".$v['goods_number']."---".$v['shop_price']."";
}追问
mysql_select_db('shop');//数据库名
mysql_query("set names utf8");//设置字符集编码
$sql="select goods_name,goods_number,shop_price from goods";//查询语句
$res=mysql_query($sql);//执行查询
while($row=mysql_fetch_assoc($res)){
$rows[]=$row;//接受结果集
}
//遍历数组
foreach($rows as $key=>$v){
echo $v['goods_name']."---".$v['goods_number']."---".$v['shop_price']."";
}追问
答非所问。你这个是查询数据库OK,
温馨提示:答案为网友推荐,仅供参考