Jump to content

tick boxes and database question


ricky spires

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/252497-tick-boxes-and-database-question/
Share on other sites

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;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.