SELECT COUNT Help
Posted: Thu Mar 18, 2010 2:59 am
Hi, I'm quite new to PHP so sorry if this is basic.
I have a MySQL database with a table in called status. There is 6 status possibilities
STATUS
In Progress
Order Received
Waiting for Artwork
Waiting for Approval
Complete
On Hold
So far this is what I have got, it counts the status and groups them and presents back as screen shot attached (Fig1) This is great but what I want it to do is present results in a table format like screen shot attached (Fig2). Where there is know result I would like a "0"
Can anyone point me in the right direction
I have a MySQL database with a table in called status. There is 6 status possibilities
STATUS
In Progress
Order Received
Waiting for Artwork
Waiting for Approval
Complete
On Hold
So far this is what I have got, it counts the status and groups them and presents back as screen shot attached (Fig1) This is great but what I want it to do is present results in a table format like screen shot attached (Fig2). Where there is know result I would like a "0"
Can anyone point me in the right direction
Code: Select all
<?php
$username="XXXX";
$password="XXXX";
$database="XXXX";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "SELECT status, COUNT(Status) FROM main_data GROUP BY status";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo "There are ". $row['COUNT(Status)'] ." Records at ". $row['status'] ." Status.";
echo "<br />";
}
?>