Wednesday 23 October 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...