我一直在从事与餐厅相关的项目,超级管理员和餐厅老板都可以更新餐厅资料。餐厅老板和管理员几乎有相同的领域,很少有不同的领域。
我的问题是有一个常见的领域是从一些食物中选择一些食物类型。的复选框。当管理员更改复选框状态时,它会完美地反映在餐厅所有者部分。但是,当餐厅所有者更改复选框状态时,它会起作用,但只有当餐厅所有者选中复选框时,如果所有者取消选中复选框,它不会更新。意味着所有者无法取消选中食物类型状态。
我不知道发生了什么,为什么它只在餐厅老板选中任何复选框时才更新,而不是在所有者取消选中任何复选框时更新。超级管理员方面一切正常。
让我知道如何解决这个问题。
我用于获取复选框的代码,这不是完整的代码..它仅用于复选框
<?php
$j=0;
$query="SELECT * FROM cuisine ORDER BY name ASC";
$rs=mysql_query($query);
while($rs1=mysql_fetch_array($rs))
{
$qid=$rs1["id"];
$qname=$rs1["name"];
$j=$j+1;
?>
<td width="200" class="style1"><input
<?php $emprolequery="select count(id) as jj from restuarantcuisine where resid='$resid' and cuisineid='$qid' ";
$emprolers=mysql_query($emprolequery) or die(mysql_error());
while($emprolers1=mysql_fetch_array($emprolers))
{
$yes=$emprolers1["jj"];
}
if($yes>0)
{
?> checked="checked"
<?php } ?>
type="checkbox" name="chkq[]" value="<?php echo $qid; ?>" /><?php echo $qname; ?> </td>
<?php
if($j%2==0 && $j!=0)
{
?>
</tr>
<tr><td> </td></tr>
<tr>
<?php }
}?>
下面的代码用于从上面的代码中接收详细信息......
<?php
ob_start();
session_start();
include("admin/conn.php");
$resid=$_REQUEST['id'];
$txtname=ltrim($_REQUEST['txtname']);
$txtemail=ltrim($_REQUEST['txtemail']);
$txtwebsite=ltrim($_REQUEST['txtwebsite']);
$txtphone=ltrim($_REQUEST['txtphone']);
$txtcellphone=ltrim($_REQUEST['txtcellphone']);
$provider=ltrim($_REQUEST['provider']);
$restaurantemail=ltrim($_REQUEST['restaurantemail']);
$txtaddress=ltrim($_REQUEST['txtaddress']);
$txtcity=strtoupper($_REQUEST['txtcity']);
$txthours=ltrim($_REQUEST['txthours']);
$txtlogo=ltrim($_REQUEST['txtlogo']);
$txtspecialcode=ltrim($_REQUEST['txtspecialcode']);
$txtdescription=addslashes($_REQUEST['txtdescription']);
$rddelivery=ltrim($_REQUEST['rddelivery']);
$delivery_fee="0";
if($rddelivery=='Y')
$delivery_fee=ltrim($_REQUEST['delivery_fee']);
$rdrescall=ltrim($_REQUEST['rdrescall']);
$txtmenu=ltrim($_REQUEST['txtmenu']);
$time1=ltrim($_REQUEST['time1']);
$time2=ltrim($_REQUEST['time2']);
$time3=ltrim($_REQUEST['time3']);
$time4=ltrim($_REQUEST['time4']);
$time5=ltrim($_REQUEST['time5']);
$time6=ltrim($_REQUEST['time6']);
$time7=ltrim($_REQUEST['time7']);
$time11=ltrim($_REQUEST['time11']);
$time22=ltrim($_REQUEST['time22']);
$time33=ltrim($_REQUEST['time33']);
$time44=ltrim($_REQUEST['time44']);
$time55=ltrim($_REQUEST['time55']);
$time66=ltrim($_REQUEST['time66']);
$time77=ltrim($_REQUEST['time77']);
if($_FILES['txtlogo']['name'])
{
$fileimage=$_FILES['txtlogo']['name'];
$ext=substr(strrchr($fileimage,'.'),1);
$rander=rand();
$logoimage=$rander.".".$ext;
$path="logo/".$logoimage;
copy($_FILES['txtlogo']['tmp_name'],$path);
$query="update restuarant set logo='$logoimage' where id='$resid'";
mysql_query($query);
}
if($_FILES['txtmenu']['name'])
{
$fileimage=$_FILES['txtmenu']['name'];
$ext=substr(strrchr($fileimage,'.'),1);
$rander=rand();
$menuimage=$rander.".".$ext;
$path="menu/".$menuimage;
copy($_FILES['txtmenu']['tmp_name'],$path);
$query="update restuarant set menu='$menuimage' where id='$resid'";
mysql_query($query);
}
$query="update restuarant set name='$txtname',address='$txtaddress', phone='$txtphone',cellphone='$txtcellphone',provider='$provider',restaurantemail='$restaurantemail',email='$txtemail', website='$txtwebsite', city='$txtcity',
description='$txtdescription', delivery='$rddelivery',delivery_fee='$delivery_fee', resorcall='$rdrescall', time1='$time1', time2='$time2', time3='$time3', time4='$time4', time5='$time5', time6='$time6', time7='$time7', time11='$time11', time22='$time22', time33='$time33', time44='$time44', time55='$time55', time66='$time66', time77='$time77' where id='$resid'";
//die($query);
//echo $query;
mysql_query($query) or die(mysql_error());
$restuarantid=mysql_insert_id();
$box[]=$_REQUEST['chkq'];
foreach ($box as $key => $value)
{
foreach ($value as $key1 => $value1)
{
$rs = mysql_query("INSERT INTO `restuarantcuisine` ( `resid`, `cuisineid`) VALUES ( '$resid','$value1' );");
}
}
header("Location:restprofile_edit.php?flag=true");
?>
我不是这个网站的原始编码员..这是我正在更新和修复一些问题的其他代码......如果我没有为此使用正确的方法,那么我如何能够根据我的需要更改复选框状态在超级管理员部分。