I’m just learning PHP and I’ve searched for a while on this, but I’m afraid I may not know exactly how to ask it, so an explanation will probably work best. Basically I have a group by/count query returning 3 records.
Status Total
0 2
1 3
2 2
On my page I would like to display:
Status Total
Dev 2
Active 3
Arch 2
So I basically just want to assign the values 0, 1 and 2 to a text value. I’ve tried creating an array, then assigning the return number field equal to the array.
$_status = array(0 => 'Development', 1 => 'Production', 2 => 'Archive');
while($rowStat = mysql_fetch_assoc($resDev))
{
echo "<tr><td>$_status[$rowStat['status']]</td><td>{$rowStat['devprojects']}</td></tr>";
};
Any help is much appreciated.
Thanks.
I don’t really like using the 0, 1, 2 to represent a named value (unless you have a relational) table in your DB… but using your setup, why not just use:
EDIT
Some people really are looking for copy-paste answers so here’s an updated answer because Sgt. Crashspeeder of the Massively Anal Society got her knickers in a twist.
Create a lookup array to reference against the status Ids:
Then when you’re running your mysql_fetch_assoc() loop, you can reference the statusArray lookup like so: