我想根据顺序选择的复选框存储值。但是我有一个错误,因为未定义的索引:productadd 等等。
设计部分:
<table width="600" style=" border-color:#799647; border-bottom-color:#799647; border-left-color:#799647; border-right-color:#799647; border-top-color:#799647;" border="2" >
<tr style="border-color:#799647; background-color:#CAF9C5;">
<td style="border-color:#799647;"><h4 style="color:Green;">Page Name</h4></td>
<td style="border-color:#799647;"><h4 style="color:Green;">Add</h4></td>
<td style="border-color:#799647;"><h4 style="color:Green;">Edit</h4></td>
<td style="border-color:#799647;"><h4 style="color:Green;">View</h4></td>
<td style="border-color:#799647;"><h4 style="color:Green;">Delete</h4></td>
</tr>
<tr style="border-color:#799647; background-color:#F5F2BF;">
<td align="center"><label>Products</label><input type="checkbox" name="screen[]" value="Products Master" align="absmiddle" /></td>
<td style="border-color:#799647;"><input type="checkbox" id="Productsadd" name="Productsadd" value="Yes" /></td>
<td style="border-color:#799647;"><input type="checkbox" id="Productsedit" name="Productsedit" value="Yes" /></td>
<td style="border-color:#799647;"><input type="checkbox" id="Productsview" name="Productsview" value="Yes" /></td>
<td style="border-color:#799647;"><input type="checkbox" id="Productsdelete" name="Productsdelete" value="Yes" /></td> </tr>
<tr style="border-color:#799647; background-color:#F5F2BF;">
<td><label>SerialNO</label><input type="checkbox" name="screen[]" value="SerialNO" /></td>
<td style="border-color:#799647;"><input type="checkbox" id="SerialNOadd" name="SerialNOadd" value="Yes" /></td>
<td style="border-color:#799647;"><input type="checkbox" id="SerialNOedit" name="SerialNOedit" value="Yes" /></td>
<td style="border-color:#799647;"><input type="checkbox" id="SerialNOview" name="SerialNOview" value="Yes" /></td>
<td style="border-color:#799647;"><input type="checkbox" id="SerialNOdelete" name="SerialNOdelete" value="Yes" /></td> </tr>
<tr style="border-color:#799647; background-color:#F5F2BF;">
<td><label>Vechile Make</label><input type="checkbox" name="screen[]" value="Vechile Make" /></td>
<td style="border-color:#799647;"><input type="checkbox" name="Vechileadd" value="Yes" /></td>
<td style="border-color:#799647;"><input type="checkbox" name="Vechileedit" value="Yes" /></td>
<td style="border-color:#799647;"><input type="checkbox" name="Vechileview" value="Yes" /></td>
<td style="border-color:#799647;"><input type="checkbox" name="Vechiledelete" value="Yes" /></td> </tr>
<tr style="border-color:#799647; background-color:#F5F2BF;">
<td><label>Retailer</label><input type="checkbox" name="screen[]" value="Retailer" /></td>
<td style="border-color:#799647;"><input type="checkbox" name="Retaileradd" value="Yes" /></td>
<td style="border-color:#799647;"><input type="checkbox" name="Retaileredit" value="Yes" /></td>
<td style="border-color:#799647;"><input type="checkbox" name="Retailerview" value="Yes" /></td>
<td style="border-color:#799647;"><input type="checkbox" name="Retailerdelete" value="Yes" /></td> </tr>
</table>
当我以前单击保存按钮时,将执行以下代码。但是我在 switch case 函数中出现错误。php代码:
if(isset($_POST['Save']))
{
$post['userid'] =($_POST['userid']);
if(!empty($_POST['userid']))
{
// if(is_array($_POST['Products']))
// {
foreach($_POST['screen'] as $post['Pagename'])
{
// myfun($post['Pagename']);
switch($post['Pagename'])
{
case "Products Master":
$post['addition'] =($_POST['Productsadd']);
$post['edit'] =($_POST['Productsedit']);
$post['vieww'] =($_POST['Productsview']);
$post['del'] =($_POST['Productsdelete']);
break;
case "SerialNO":
$post['addition'] =($_POST['SerialNOadd']);
$post['edit'] =($_POST['SerialNOedit']);
$post['vieww'] =($_POST['SerialNOview']);
$post['del'] =($_POST['SerialNOdelete']);
break;
case "Vechile Make":
$post['addition'] =($_POST['Vechileadd']);
$post['edit'] =($_POST['Vechileedit']);
$post['vieww'] =($_POST['Vechileview']);
$post['del'] =($_POST['Vechiledelete']);
break;
case "Retailer":
$post['addition'] =($_POST['RetailerOadd']);
$post['edit'] =($_POST['Retaileredit']);
$post['vieww'] =($_POST['Retailerview']);
$post['del'] =($_POST['Retailerdelete']);
break;
default :
?>
<script type="text/javascript">
alert("Nothing selected.!!");document.location='userrights.php';
</script>
<?
}
//echo $post['Pagename'];
$news->addNews($post);
// }
}
?>
<script type="text/javascript">
alert("Created Sucessfully..!!");document.location='userrights.php';
</script>
<?
}
}
![this is my visual screen][1]