mysql count rows php code example
Example 1: 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 2: 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);
}
?>