在php中编辑期间的复选框问题

时间:2014-04-26 16:40:10

标签: php codeigniter cakephp

这是广告查询

INSERT into advertise_management(advertisement_name,adv_code) values('".$adv_name."','".$adv_code."')

后期管理:

<input type="text" name="post_name" value="<?php if(isset($post_value)){ echo $post_value['post_name'];} else { echo ''; }?>" required="required">
<?php  $res=  mysql_query("select * from advertise_management ");
while($result= mysql_fetch_array($res)){
    $adv=$result['advertisement_name'];
{ ?>
<input type="checkbox" value="<?php echo $adv?>" name="post_adv[]">
<?php } ?>

邮政管理插入查询:

$post_name = $_POST['post_name'];  
$post_adv1 = $_POST['post_adv'];
$post_adv = implode(",", $post_adv1);
$post_id = $_POST['post_id'];
$res = mysql_query("INSERT into post_managment(post_name,post_adv) values('".$post_name."','".$post_adv."')") or die(mysql_error());

管理后编辑:

$result = mysql_query("SELECT * FROM   post_managment where post_id='$pid'");

$post_value = mysql_fetch_array($result);  
><input type="text" name="post_name" value="<?php if(isset($post_value)){ echo $post_value['post_name'];} else { echo ''; }?>" required="required">

<?php  $res=  mysql_query("select * from advertise_management ");
while($result= mysql_fetch_array($res)){
    $adv=$result['advertisement_name'];
{ ?>
<input type="checkbox" value="<?php echo $adv?>" name="post_adv[]">
<?php } ?>
<input type="submit" value="" id="create"><input type="reset" value="" id="cancel">

我想返回检查的值和未检查的值。

1 个答案:

答案 0 :(得分:2)

浏览器通常不会为未选中的复选框发送任何内容。您可以通过渲染具有相同名称和不同值的隐藏输入()来解决此问题。确保它在复选框之前输出。