I'm trying to count all my project in project table
Project_Name is a column_name
Here is the my code I have tried:
$sql = "SELECT COUNT(*) FROM project";
$result = $connection->query($sql);
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$project_count = $row['Project_Name'];
}
else {
echo "0 results";
}
?>
Answer
Try this
$sql = "SELECT COUNT(*) FROM project";
$result = $connection->query($sql);
if ($result->num_rows > 0) {
$row =$result->fetch_array();
$project_count = $row[0];
}
No comments:
Post a Comment