<?php $sql=mysql_query("selectcount(*)astotalfromtb_leaveword",$conn);$info=mysql_fetch_array($sql);$total=$info[total];if($total==0){echo"对不起,暂无留言...
$sql=mysql_query("select count(*) as total from tb_leaveword ",$conn);
$info=mysql_fetch_array($sql);
$total=$info[total];
if($total==0){
echo "
}else{
if(!isset($_GET["page"]) || !is_numeric($_GET["page"])){
$page=1;
}else{
$page=intval($_GET["page"]);
}
$pagesize=3;
if($total%$pagesize==0){
$pagecount=intval($total/$pagesize);
}else{
$pagecount=ceil($total/$pagesize);
}
$sql=mysql_query("select * from tb_leaveword order by createtime desc limit ".($page-1)*$pagesize.",$pagesize ",$conn);
while($info=mysql_fetch_array($sql)){
?>
$sqlu=mysql_query("select usernc from tb_user where id='".$info["userid"]."'",$conn);
$infou=mysql_fetch_array($sqlu);
if($infou["usernc"]==$_SESSION["unc"]){
?>
上面是教科书中同在留言板index.php文件下的二段编码,本留言板有二个数据库tb_user(用来存放用户的各项住处)tb_leaveword(用于存放用户的留言和留言标题),第二段中$sqlu=mysql_query("select usernc from tb_user where id='".$info["userid"]."'",$conn);这一段中的id='".$info["userid"]."' 我查到$info["userid"]的值都是1,为什么会达到SQL要求的选中所选数据条的作用呢?每个ID都等于1,就能选到数据条了吗?
展开