php一个基础问题 想请教下大家。
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
$conn=mysql_connect("localhost","root","123456");
if(!$conn){
die('could not connect:'.mysql_error());
}
else{
echo '链接正常<br />';
}
mysql_select_db("zuitu_db",$conn);
$sql="select * from category order by id desc"; // $sql="select * from 'category'";这样写有错吗?
$res=mysql_query($sql);
$i=1;
$strTemp='';
/*
下面这个while循环,为何读不出数据?
*/
while($row=mysql_fetch_array($res)){
if($i==1)
{
$strTemp=$row["name"];
}
else
{
$strTemp+='<br />'.$row["name"];
}
// ($i==1)?$strTemp=$row["name"]:strTemp+='<br />'.$row["name"]; 这样写有误吗?
$i+=1;
}
echo $strTemp;
//以上内容 请大家帮忙指正,多谢!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号