ricky spires Posted December 5, 2011 Share Posted December 5, 2011 hello. i have a question for you. say i have a group of tick boxes and i select a couple. would i put them in to the database as varchar ? like this: id varchar 1 1, 2, 3 or id varchar 1 '1', '2', '3' then my next question is how would i use them. i guess i would explode them or something. the thing is, i have some code that currently pull 1 item from the database (using varchar) and echos it fine but when i add more i get nothing back. thanks rick Quote Link to comment https://forums.phpfreaks.com/topic/252497-tick-boxes-and-database-question/ Share on other sites More sharing options...
ricky spires Posted December 5, 2011 Author Share Posted December 5, 2011 this is the code that works if i just put 1 value in to the db: id varchar 1 the name will return "the name" function include_admin_contElements($phNo, $pageID){ $pha = Placeholders::find_by_pageID($pageID); foreach ($pha as $phas){ $PHceA = $phas->contElements_id; $PHnA = $phas->phNumber; $CEa = Contelements::find_all(); foreach ($CEa as $CEas){ $CEidA = $CEas->id; $CEnameA = $CEas->name; if($PHceA == $CEidA && $PHnA == $phNo){ echo $CEnameA."<br/>"; } } } } this part retutns the element name if($PHceA == $CEidA && $PHnA == $phNo){ echo $CEnameA."<br/>"; } i tried putting more value in the db like this id varchar 1 name 1, name 2, name 3 or id varchar 1 'name 1', 'name 2', 'name 3' and adding explode to my code but i still get nothing returned: if($PHceA == $CEidA && $PHnA == $phNo){ explode("-",$CEnameA); echo $CEnameA; } Quote Link to comment https://forums.phpfreaks.com/topic/252497-tick-boxes-and-database-question/#findComment-1294533 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.