At least I am guessing this is simple. I have been writing a very basic page that returns results from MySql and I have learned a lot but I am stuck on one of my goals for the page. Here goes:
One of the fields is a status field (S, P, V) I figured out how to limit those fields when I search but I need to also be able to add a status result to my results page. Basically if status=P then echo "Order Invoiced";
I haven't been able to dig up any tutorials for this one so I have resorted to begging.
Thanks guys
Simple question from a newbie
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Simple question from a newbie
You could have another table with the code and text descriptions and you could join the two tables. The table would be like:
table status_codes:
And the SQL would be:
Or you could do it in PHP with an array:
table status_codes:
Code: Select all
id description
S Whatever S is
P Order Invoiced
V Whatever V isCode: Select all
SELECT * FROM orders JOIN status_codes ON order.status=status_codes.id WHERE ...Code: Select all
$status_codes = array(
'S' => 'Whatever S is',
'P' => 'Order Invoiced',
'V' => 'Whatever V is',
);
echo $status_codes[$row['status']];
(#10850)
Re: Simple question from a newbie
I knew it would be something simple.
Worked perfectly.
Thanks
Worked perfectly.
Thanks