Jump to content

Checkbox


thecase

Recommended Posts

Hi,

 

This is part of my table code

 

     		 echo "<td align=\"center\"><font color=\"{$colors[$row['presenter1status']]}\">{$row['presenter1']}</font> <input type='checkbox' /></td>"; 

 

Now what I was hoping to do is write some code to check what is selected and what isnt to be then able to write some queries to the database. Can anyone give any pointers

 

Thanks

Link to comment
Share on other sites

I know this but the problem is there will be like 50 records with 50 checkboxs so how can I define all 50 of them

 

On your html, set the name for the checkboxes the same and the value something unique. Then you only have to check one.

Link to comment
Share on other sites

On your html, set the name for the checkboxes the same and the value something unique. Then you only have to check one.

 

So if the user selects 10 out of the 50 checkboxes will all the same name im not sure how I can take the selected data and input it into the database for example if checked update table users feild admin and make it 1.

Link to comment
Share on other sites

On your html, set the name for the checkboxes the same and the value something unique. Then you only have to check one.

 

So if the user selects 10 out of the 50 checkboxes will all the same name im not sure how I can take the selected data and input it into the database for example if checked update table users feild admin and make it 1.

 

I see what your saying, but I'd really have to see your code. It really depends on how it's written to see how to do it.

Link to comment
Share on other sites

could you do something like this?

 


<?php

#with something like this you could have 100 individualy names checkboxes 
#and only process the valid few

if(!empty($_REQUEST['submit'])){
#have a look at all the requests
print_r($_REQUEST);
echo "<br /><br />";
$total =0;

	#look at each request
	foreach($_REQUEST as $a)
	{
		#if the request has a * in it 
		if(strpos($a,'*'))
		{
			#chop it into two parts
			$b = explode('*',$a);
			#if the first part is SELECTME	
			if($b[0] = 'SELECTME');
			{
				#increment total buy part 2 (the intended value from the check box)
				#or other do syuff code 
				#i.e. 
				$sql ="insert into table_name(total) values('$b[1]')"; 
				$total = $total + $b[1];
			}
		}
	}

echo "total: ".$total;

}
?>

<form name="form1" action="?" method="post">

    <?php for($i=0; $i<=9; $i++){ ?>
    	<input name="check<?php echo $i;?>" type="checkbox" value="SELECTME*10" />
<?php } ?>
    <input type="submit" name="submit" value="go" />

</form>

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.