<?php
$q = isset($_POST["q"]) ? intval($_POST["q"]) : "";
if(empty($q)) {
echo 'please choose a web site';
exit;
}
$con = mysqli_connect('localhost','root','');
if(!$con) {
die('Could not connect : '.mysqli_error($con));
}
//choose database
mysqli_select_db($con,'sixfive');
//set charset
mysqli_set_charset($con,'utf8');
$sql = "select * from websites where id='".$q."'";
$result = mysqli_query($con,$sql);
echo "<table border='1'>";
echo "<tr>";
echo "<th>ID</th>";
echo "<th>SiteName</th>";
echo "<th>SiteURL</th>";
echo "<th>ALex</th>";
echo "<th>Country</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>".$row['id']."</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
$q是接受Ajax传过来的q的值
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>".$row['id']."</td>";
echo "</tr>";
}
这个while中的 条件判断不会死循环吗? 运行结果是没有死循环 $row = mysqli_fetch_array($result) 返回的值不是一直是true吗?但是运行结果正常 哪里的问题呢?
- 1 回答
- 0 关注
- 604 浏览
添加回答
举报
0/150
提交
取消