My code is like this:
<?php
$con=mysqli_connect("localhost","root","root","store");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM admin");
$existCount = mysql_num_rows($sql);
echo "the total number is".mysql_num_rows($sql)."<br/>";
while($row = mysqli_fetch_array($result))
{
echo $row['username'] . " " . $row['password'];
echo "<br />";
}
mysqli_close($con);
?>
The result is like this:
the total number is
admin admin
jack admin
......
I built a very easy query to test my code, then found out mysql_num_rows() does not work, why I can not get the number of the records in the database. There are only three attibutes and ten records in the table. And my the version of my PHP is 5.3.23. I spent the whole night trying to find out the problem, really do not know what is wrong.:bemused: