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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.