php mysql_fetch_array中,怎样为什么只是输出一条记录呢?
functiongetUsers(){$sql=<<<EOFSELECT*FROMusersEOF;//var_dump($sql);break;$result=mysq...
function getUsers(){
$sql = <<<EOF
SELECT * FROM users
EOF;
// var_dump($sql);break;
$result = mysql_query($sql);
if($result){
while($rows = mysql_fetch_array($result,MYSQL_ASSOC)){
$id = $rows["id"];
$username = $rows["username"];
$password = $rows["password"];
$email = $rows["email"];
$cellphone = $rows["cellphone"];
$str = "";
$str .="<tr>";
$str .="<td>$id</td>";
$str .="<td>$username</td>";
$str .="<td>$password</td>";
$str .="<td>$cellphone</td>";
$str .="<td>$email</td>";
$str .="<td><a href='#'>编辑</a><a href='#'>删除</a></td>";
// var_dump($result);
return $str;
}
}
} 展开
$sql = <<<EOF
SELECT * FROM users
EOF;
// var_dump($sql);break;
$result = mysql_query($sql);
if($result){
while($rows = mysql_fetch_array($result,MYSQL_ASSOC)){
$id = $rows["id"];
$username = $rows["username"];
$password = $rows["password"];
$email = $rows["email"];
$cellphone = $rows["cellphone"];
$str = "";
$str .="<tr>";
$str .="<td>$id</td>";
$str .="<td>$username</td>";
$str .="<td>$password</td>";
$str .="<td>$cellphone</td>";
$str .="<td>$email</td>";
$str .="<td><a href='#'>编辑</a><a href='#'>删除</a></td>";
// var_dump($result);
return $str;
}
}
} 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询