0

I'm playing around with PHP. My issue is that my SELECT query with the COUNT() function is only returning one row, however when I query the database directly through phpmyadmin with what it echoes, the same query is returning the correct number of rows (three).

$servername = "localhost";
$username = "admin_browser";
$password = "BrowserPw";
$dbname = "admin_database";

$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT COUNT('$field') FROM $table";
echo ($sql . "<br />");
$max = mysqli_num_rows(mysqli_query($conn, $sql)); 
echo ($max . " rows returned <br />"); // 1 rows returned
Kyle Diablo
  • 61
  • 1
  • 7

0 Answers0