Wednesday, October 23, 2019

javascript - Undefined index: Project_Name




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

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...