Code: Select all
if(isset($_POST['update'])){
for($i=1; $i<=$_POST['colCount'];$i++){
echo "<br/> value for ".$i." is ".$_POST[$i];
}
}
<form action="test.php" method="post">
<input type="hidden" name="1" value="no"/>
<input type="checkbox" name="1" value="news" />News
<input type="hidden" name="2" value="no"/>
<input type="checkbox" name="2" value="rss" />Rss
<input type="hidden" name="colCount" value="2"/>
<input type="submit" name="update" value="submit" />
</form>
So, if I do
Code: Select all
foreach($_POST['chk']) as $checkbox){
...code here to print values...(no/yes)
}
Ideal case would be to have something similar to this
Code: Select all
<input type="hidden" name="news_title" value="no">
<input type="checkbox" name="news_title" value="yes">
<input type="hidden" name="news_des" value="no">
<input type="checkbox" name="news_des" value="yes">
Code: Select all
$_POST['news_title'];
$_POST['news_des'];
In this case, how do I update a database table based on mere values when I dont know which check boxes have been clicked (their name) ?
Do I make any sense?