Created
October 21, 2013 06:26
-
-
Save abdullahbutt/7079454 to your computer and use it in GitHub Desktop.
PHP mysqli_num_rows() Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$con=mysqli_connect("localhost","my_user","my_password","my_db"); | |
// Check connection | |
if (mysqli_connect_errno($con)) | |
{ | |
echo "Failed to connect to MySQL: " . mysqli_connect_error(); | |
} | |
$sql="SELECT Lastname,Age FROM Persons ORDER BY Lastname"; | |
if ($result=mysqli_query($con,$sql)) | |
{ | |
// Return the number of rows in result set | |
$rowcount=mysqli_num_rows($result); | |
printf("Result set has %d rows.\n",$rowcount); | |
// Free result set | |
mysqli_free_result($result); | |
} | |
mysqli_close($con); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment