php count rows code example
Example 1: php string length
<?php
$str = 'abcdef';
echo strlen($str);
$str = ' ab cd ';
echo strlen($str);
?>
Example 2: mysql rowcount php
<?php
$link = mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("database", $link);
$result = mysql_query("SELECT * FROM table1", $link);
$num_rows = mysql_num_rows($result);
echo "$num_rows Zeilen\n";
?>
Example 3: php num rows
<?php
$con = mysqli_connect("localhost", "root", "", "testing");
if (mysqli_connect_errno()) {
echo "Database connection failed.";
}
$query = "SELECT Username, Password FROM users";
$result = mysqli_query($con, $query);
if ($result) {
$row = mysqli_num_rows($result);
if ($row) {
printf("Number of row in the table : " . $row);
}
mysqli_free_result($result);
}
?>
Example 4: php mysqli number row
mysqli_num_rows($result);