Thanks,
Your assumptions were correct, I'll give that a try.
I ended up doing this which doesn't seem as efficient:
$item_array = array('Mens Ring' => m_r,
'Mens Charm' => m_c,
'Womens Ring' => w_r,
'Womens Charm' => w_c
);
while (list($val, $key) = each($item_array)){
if ($key == $item){
$item_text = $val;
}
}
echo $item_text;
Thanks again,
Robert
- Original Message -
From: "Matthew Loff" <[EMAIL PROTECTED]>
To: "'Robert Weeks'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, December 21, 2001 4:26 PM
Subject: RE: [PHP-DB] Hashes
>
> Robert--
>
> You're on the right track... I'm assuming $row is the result of a
> mysql_fetch_assoc() call, and $row['item'] contains the hashed value
> (either "m_r", "m_c", or whatever)... Try this:
>
>
> $item_list = array('Mens Ring' => m_r, 'Mens Charm' => m_c, 'Womens
> Ring' => w_r,'Womens Charm' => w_c);
>
> #query db and get a result snipped
>
> echo $item_list[$row['item']];
>
> ?>
>
> Good luck,
> Matt
>
>
> -Original Message-
> From: Robert Weeks [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 21, 2001 11:27 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Hashes
>
>
> I'm trying to use a hash to translate a value into something human
> readable. I know how to do this with an if-else but that seems like a
> waste of typing.
>
> I have a bunch of items in the db and their values are abbreciations
> such as 'm_r'. I want m_r to show on the page as "Mens Rings". I was
> trying to do it like this but echo $item returned "Array":
>
> #query db and get a result snipped
>
> $item = $row[item];
>
> $item = array('Mens Ring' => m_r, 'Mens Charm' => m_c, 'Womens Ring' =>
> w_r,'Womens Charm' => w_c);
>
> echo $item;
>
> ?>
>
> Any help would be appreciated.
>
> thnx,
>
> robert
>
>
>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]