I am new to PHP and learning how to retrieve data from a database into html. I have created a database in go-daddy with a simple test table called "Fruits" with four rows and 3 columns and it has data in it. When I try to pull the data into html, it seems like there is no data in it (or php is not reading the data). Is able to count the number of rows properly (4) and return that, but when I count the values in the table, it says 0. So when I try to later use the fetch_array command, nothing is outputting. Any advise anyone can provide is much appreciated.
Here is the code:
<?php
echo "<p>PHP is enabled</p>";
$host="localhost";
$user="me";
$password="mypassword";
$dbname = "TestDB";
$cxn = mysqli_connect($host,$user,$password,$dbname) or die("Couldn't
connect to server.");
$query = "SELECT * FROM Fruits";
if ($result=mysqli_query($cxn,$query)){
// Return the number of rows in result set
$rowcount=mysqli_num_rows($result);
printf("Result set has %d rows.
",$rowcount);
//Return the number of values in result set
$size=array_count_values($result);
printf("Result set has %d values.
",$size);
// Free result set
mysqli_free_result($result);
}
mysql_close($cxn);
?>