php 复选框的用法 我原来在一个表中最前面加了一列复选框,现在我想以数组的形式读 出复选框的值,并显示被选中的复选框后面的一条记录,请各位大侠给点意见 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <input type="checkbox" name="c[]">1<input type="checkbox" name="c[]">2<input type="checkbox" name="c[]">3<?php$count = count($_POST['c']);echo $_POST['c'][$count-1]; //3?> <input type="checkbox" name="c[]">1<input type="checkbox" name="c[]">2<input type="checkbox" name="c[]">3能不能改为不固定的个数啊,就是用数组那样的,因为我的那个表是用数组输出的,行数挺多 是不是按纽的意思啊,我刚学,很多不明白,请前辈多多指教,for($n = 0; $n < 8; $n++){<input type="checkbox" name="c[]" value="1">}输出的只有一个,我想得到所有的,可以吗 <?phpvar_dump($_POST);?> 不知道该怎么跟你讲,参考代码:<script language=Javascript>function checkAll(e, itemName){ var aa = document.getElementsByName(itemName); for (var i=0; i<aa.length; i++) aa[i].checked = e.checked;}function checkItem(e, allName){ var all = document.getElementsByName(allName)[0]; if(!e.checked) all.checked = false; else { var aa = document.getElementsByName(e.name); for (var i=0; i<aa.length; i++) if(!aa[i].checked) return; all.checked = true; }}</script><form action="query.php" method="post" name="form1"> <table width="98%" border="0"> <tr> <td valign="top" nowrap>指定用户</td> <td nowrap><table width="462" border="0"> <tr> <td width="44" height="16">选择</td> <td width="180">公司名</td> <td width="107">用户名</td> <td width="113">用户姓名</td> </tr> <?php while ($row_user = $result_user->fetchRow(DB_FETCHMODE_ASSOC)) { ?> <tr> <td height='16'><input name="selectIt[]" type="checkbox" id="selectIt[]" value="<?php echo $row_user['user_id'] ?>"></td> <td><?php echo $row_user['user_category'] ?></td> <td><?php echo $row_user['user_uid'] ?></td> <td><?php echo $row_user['user_name'] ?></td> </tr> <?php } ?> </table></td> </tr> <tr><td> </td> <td colspan="2" nowrap> <input type=checkbox name=mmAll onClick="checkAll(this, 'selectIt[]')">全选与反选切换 </td></tr> <tr> <td colspan="2" nowrap> <input type="submit" name="Submit" value="提交"> <input name="Reset" type="reset" id="Reset" value="重置"> </td> </tr> </table></form> wasuka和wwx840723讲的很好啊!楼主好好看看。 求助 php 无法连接 mysql 怎么回事呢 phpStudy 1.7.0 基础问题 我是菜鸟 求一sql 【♣】phpMyAdmin IE 下无法登陆,Firefox 和Google 浏览器都可以登录 如何让php显示语法错误 询问一个时间问题 关于“||”的问题? mysql使用问题. 值为 0 怎样输出 我已经在PHP.INI中定义了session.save_path = "e:\server\php\tmp"为什么还不行。(其中tmp是我新建的文件夹) 急 复选框问题
<input type="checkbox" name="c[]">2
<input type="checkbox" name="c[]">3<?php
$count = count($_POST['c']);
echo $_POST['c'][$count-1]; //3
?>
<input type="checkbox" name="c[]">2
<input type="checkbox" name="c[]">3能不能改为不固定的个数啊,就是用数组那样的,因为我的那个表是用数组输出的,行数挺多
for($n = 0; $n < 8; $n++)
{<input type="checkbox" name="c[]" value="1">}
输出的只有一个,我想得到所有的,可以吗
var_dump($_POST);
?>
<script language=Javascript>
function checkAll(e, itemName)
{
var aa = document.getElementsByName(itemName);
for (var i=0; i<aa.length; i++)
aa[i].checked = e.checked;
}
function checkItem(e, allName)
{
var all = document.getElementsByName(allName)[0];
if(!e.checked) all.checked = false;
else
{
var aa = document.getElementsByName(e.name);
for (var i=0; i<aa.length; i++)
if(!aa[i].checked) return;
all.checked = true;
}
}
</script>
<form action="query.php" method="post" name="form1">
<table width="98%" border="0"> <tr>
<td valign="top" nowrap>指定用户</td>
<td nowrap><table width="462" border="0">
<tr>
<td width="44" height="16">选择</td>
<td width="180">公司名</td>
<td width="107">用户名</td>
<td width="113">用户姓名</td>
</tr>
<?php while ($row_user = $result_user->fetchRow(DB_FETCHMODE_ASSOC)) { ?>
<tr>
<td height='16'><input name="selectIt[]" type="checkbox" id="selectIt[]" value="<?php echo $row_user['user_id'] ?>"></td>
<td><?php echo $row_user['user_category'] ?></td>
<td><?php echo $row_user['user_uid'] ?></td>
<td><?php echo $row_user['user_name'] ?></td>
</tr>
<?php } ?>
</table></td>
</tr>
<tr><td> </td>
<td colspan="2" nowrap>
<input type=checkbox name=mmAll onClick="checkAll(this, 'selectIt[]')">全选与反选切换
</td></tr>
<tr>
<td colspan="2" nowrap> <input type="submit" name="Submit" value="提交">
<input name="Reset" type="reset" id="Reset" value="重置"> </td>
</tr>
</table>
</form>