Hello Everyone,I was learning connecting MySQLi with PHP.I wanted to display the names of all the databases on my server.I used the following code.
<?php
$server = 'localhost';
$user = 'root';
$pass = 'pass';
$mysqli = new mysqli($server,$user,$pass);
if($mysqli->connect_error)
die("Could not connect to server.<br/>");
$query = "SHOW DATABASES";
if($result = $mysqli->query($query))
{
while($row = $result->fetch_row())
{
printf("%s<br/>",$row[0]);
}
}
?>
I am getting the desired result,but I didi not understand the functions fetch_row() and fetch_assoc properly.
and why are we using the indice '0' in the line
printf("%s<br/>",$row[0]);
I tried using 1,but it gave me errors.I did not understand what was given on php.net manual.
Someone please explain me in detail.
Thank you.