RE: [PHP-DB] Hashes

From: Date: Fri, 21 Dec 2001 21:26:08 +0000
Subject: RE: [PHP-DB] Hashes
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-15189@lists.php.net to get a copy of this message
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: <?php $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:robert@woozy.com] Sent: Friday, December 21, 2001 11:27 AM To: php-db@lists.php.net 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": <?php #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

« previous php.db (#15189) next »