Mysqli_fetch_array cycle problem

<?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?

Php
Mar.18,2021
The

mysqli_fetch_array function returns a row from the result set. If there are no more rows, it returns false, so the


mysqli_fetch_array of this operation points the current record to the next one every time it gets a piece of data. When it reaches the end of the record, the function returns false, to exit the while loop

.
Menu