PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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"
<?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 />";
}
?>
Attachments
fig2
fig2.png (19.72 KiB) Viewed 318 times
Fig1
fig1.png (12.83 KiB) Viewed 318 times
Last edited by Benjamin on Thu Mar 18, 2010 3:16 am, edited 1 time in total.
Reason:Added [code=php] tags.
Thanks for Help, but I'm still a bit confused, below is where I have got to, is this correct so far? I need the result of the COUNT query to display in corresponding table. I have formatted the table but not sure where to go from here, sorry Thanks in advance.