jarv Posted August 4, 2011 Share Posted August 4, 2011 hi, on my site I have 6 checkboxes: Box1 = Internet Box2 = Yellow pages Box3 = Van Box4 = Letting agent Box5 = Repeat customer Box6 = Recommendation which ever is checked they go into the database as a number, for example, if all were checked I get 0|1|2|3|4|5 in my database. This all works fine but, I need to show which are checked, if my database had: 0|2|4 I need it to say: Internet, Van, Repeat Customer please help? Link to comment https://forums.phpfreaks.com/topic/243828-numbered-array-in-database-need-to-show-as-text/ Share on other sites More sharing options...
WebStyles Posted August 4, 2011 Share Posted August 4, 2011 $names = array('Internet','Yellow pages','Van','Letting agent','Repeat customer','Recommendation'); // assuming you have a var called $dbValues with the results from database and that it looks like this: 0|1|3 $dbNumbers = explode("|",$dbValues); $n = array(); foreach($dbNumbers as $num){ $n[]=$names[$num]; } echo implode(", ",$n); Link to comment https://forums.phpfreaks.com/topic/243828-numbered-array-in-database-need-to-show-as-text/#findComment-1251930 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.