php要求同名表单元素用数组形式命名,并赋予value。否则他不能分解。
例:
<input type=checkbox name="chk[]" value=1>
<input type=checkbox name="chk[]" value=2>
<input type=checkbox name="chk[]" value=3>提交后,用$_POST['chk']访问。数组中的元素为选中的复选框的值
例:
<input type=checkbox name="chk[]" value=1>
<input type=checkbox name="chk[]" value=2>
<input type=checkbox name="chk[]" value=3>提交后,用$_POST['chk']访问。数组中的元素为选中的复选框的值
{
foreach ($test as $val) {
echo $val."<br>";
}
}
$a=1;
$b=3;
?>
<form action="<?=$PHP_SELF;?>" method="post">
<input type="checkbox" name="test[]" value="1">
<input type="checkbox" name="test[]" value="2">
<input type="checkbox" name="test[]" value="3">
<input type="submit" name="submit" value="submit">
</form>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<?
if($check)
{
for($i=1;$i<=$countselected;$i++)
{
echo $checkboxid[$i]."<br>";
}
}
?>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<table width="80%" border="0" cellspacing="0" cellpadding="0" align="center">
<?
for($i=1;$i<=5;$i++)
{
?>
<tr>
<td>
<input type="checkbox" name="checkboxid[<?echo $i?>]" value="选择[<?echo $i?>]">
选择<?echo $i?>
</td>
</tr>
<?
}
?>
<input type="hidden" name="countselected" value="<?echo $i?>">
<tr>
<td>
<input type="submit" name="check" value="Submit">
</td>
</tr>
</table>
</form>
</body>
</html>
全在这
if($submit)
{
foreach ($test as $val) {
echo $val."<br>";
}
}
?>
<form action="<?=$PHP_SELF;?>" method="post">
<input type="checkbox" name="test[]" value="1">
<input type="checkbox" name="test[]" value="2">
<input type="checkbox" name="test[]" value="3">
<input type="submit" name="submit" value="submit">
</form>
<input type=checkbox value=3 name=product[]>
38度劲酒
<input type=checkbox value=4 name=product[]>
500ML八角劲
<input type=checkbox value=5 name=product[]>
防伪小八角劲
<input type=checkbox value=6 name=product[]> 提交后,用$_POST['product']访问 输出值为 Array 为什么呢?
echo $val."<br>";
}
可以参看我网站中音乐连播的部分:http://www.musicyear.net
<html><head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>AB C</title>
</head><body>
<form method="POST" action="po.php"><input type=checkbox name="chk[]" value=1> A<input type=checkbox name="chk[]" value=2>B
<input type=checkbox name="chk[]" value=3>C
<input type="submit" value="提交" name="B1"><input type="reset" value="重置" name="B2">
</from>
</body></html>========htm================po.php=======
<?php
extract($_GET);
extract($_POST);
echo $chk[0];
?>
=====================以上我只作了一个数组变量,要其它的可以用一个循环.$chk[0];修改0可得到其它的值.
其中每一项对应所选中的复选框的value
根据这些值可以做你需要的工作。“要把这些值放到数据库。”
如何放由你的库结构决定,别人如何代劳
多谢各位高人的指点
我的劲酒注册系统搞好后请大家喝劲酒,哈哈,常来光顾还有大奖,先做个广告哈。呵呵
中国劲酒网址:www.jingjiu.com
gameboys(gameboys)兄台呀