When I used while loop to print the values of a particular column using mysqli_fetch_array(), I got the correct output from the database.
while($row=mysqli_fetch_array($data))
{
echo $row['name'];
}
But when I used the below mentioned code without the loop, the output was different.
$row=mysqli_fetch_array($data);
echo $row['name'];
echo $row['name'];
echo $row['name'];
echo $row['name'];
echo $row['name'];
echo $row['name'];
When I used the below mentioned code, I could see that I get all the rows in the form of an associative array using mysqli_fetch_array().
$con=mysqli_connect("localhost", "root", "", "student_details");
$data=mysqli_query($con,"select * from `registration`");
while ($row = mysqli_fetch_array($data))
{
$rec[]=$row;
}
echo "<pre>";
print_r($rec);
echo "</pre>";
?>
My question is how to get all the values of a particular column (using a while loop), without usage of any loop.