954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

PHP Checkbox Variable

Hi,
What i want is to have a checkbox area where the items i select are stored in a array. Im guessing there should be a some code to find out what has been checked.
Any help with this would be greatly appreciated.

echo '<form action="myown3.php" method="post" name="domaintest" action="_self">';
	
	echo '<input name="submitform" type="submit" value="Submit Domain Info">';
		foreach($domains->domainName as $value) {
echo (' <label><input type="checkbox" name="domain_custom" value="'.$value.'" id="'.$value.'">'.$value.'</label>');
		}	
	echo '</form>';
tyrium
Newbie Poster
4 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

using arrays we can store multiple values. for array see w3school .com tutorial

rajabhaskar525
Junior Poster
179 posts since Nov 2009
Reputation Points: 12
Solved Threads: 27
 

Hi, What i want is to have a checkbox area where the items i select are stored in a array. Im guessing there should be a some code to find out what has been checked. Any help with this would be greatly appreciated.

echo '<form action="myown3.php" method="post" name="domaintest" action="_self">';
	
	echo '<input name="submitform" type="submit" value="Submit Domain Info">';
		foreach($domains->domainName as $value) {
echo (' <label><input type="checkbox" name="domain_custom" value="'.$value.'" id="'.$value.'">'.$value.'</label>');
		}	
	echo '</form>';


are you looking for this?

$box=$_POST['box'];

while (list ($key,$val) = @each ($box)) {
echo "$val,";
}

echo "<form method=post action=''>";
echo "<table border='0' cellspacing='0' style='border-collapse: collapse' width='100' >
<tr bgcolor='#ffffff'>
<td width='25%'><input type=checkbox name=box[] value='John'></td>
<td width='25%'>&nbsp;John</td>
<td width='25%'><input type=checkbox name=box[] value='Mike'></td>
<td width='25%'>&nbsp;Mike</td>
<td width='25%'><input type=checkbox name=box[] value='Rone'></td>
<td width='25%'>&nbsp;Rone</td>
</tr>
<tr bgcolor='#f1f1f1'>
<td width='25%'><input type=checkbox name=box[] value='Mathew'></td>
<td width='25%'>&nbsp;Mathew</td>
<td width='25%'><input type=checkbox name=box[] value='Reid'></td>
<td width='25%'>&nbsp;Reid</td>
<td width='25%'><input type=checkbox name=box[] value='Simon'></td>
<td width='25%'>&nbsp;Simon</td>
</tr>

<tr><td colspan =6 align=center><input type=submit value=Select></form></td></tr>
</table>";
muralikalpana
Posting Pro
540 posts since Sep 2009
Reputation Points: 21
Solved Threads: 36
 

are you looking for this?

$box=$_POST['box'];

while (list ($key,$val) = @each ($box)) {
echo "$val,";
}

echo "<form method=post action=''>";
echo "<table border='0' cellspacing='0' style='border-collapse: collapse' width='100' >
<tr bgcolor='#ffffff'>
<td width='25%'><input type=checkbox name=box[] value='John'></td>
<td width='25%'>&nbsp;John</td>
<td width='25%'><input type=checkbox name=box[] value='Mike'></td>
<td width='25%'>&nbsp;Mike</td>
<td width='25%'><input type=checkbox name=box[] value='Rone'></td>
<td width='25%'>&nbsp;Rone</td>
</tr>
<tr bgcolor='#f1f1f1'>
<td width='25%'><input type=checkbox name=box[] value='Mathew'></td>
<td width='25%'>&nbsp;Mathew</td>
<td width='25%'><input type=checkbox name=box[] value='Reid'></td>
<td width='25%'>&nbsp;Reid</td>
<td width='25%'><input type=checkbox name=box[] value='Simon'></td>
<td width='25%'>&nbsp;Simon</td>
</tr>

<tr><td colspan =6 align=center><input type=submit value=Select></form></td></tr>
</table>";


Yea something like that, but there are over 2000 domain names and more and more are added all the time.

tyrium
Newbie Poster
4 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

Great help muralikalpana,

This is the code i got so far

$box=$_POST['box'];

while (list ($key,$val) = @each ($box)) {
echo "$val,";
}

echo "<form method=post action=''>";
foreach($domains->domainName as $value) {
echo "<input type=checkbox name=box[] value='".$value."'>";
echo "&nbsp;".$value."";
}
echo "<input type=submit value=Select></form>";


There are over 2000 domain names so i was wondering if there is a way to format it in a table so once it reaches something like 200 domains the table will continue on a second column and so on...

tyrium
Newbie Poster
4 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: