<?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 is the value of Q passed by Ajax
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>".$row["id"]."</td>";
echo "</tr>";
}
won"t conditional judgments in this while be cyclical? The result of the run is that there is no endless loop $row = mysqli_fetch_array ($result)
. Isn"t the value always true? But what"s wrong with the normal results?