<?
if($ok){
while(list($key,$val)=each($hehe))
echo "$val<br>";
}
?>
<form action="" method=post>
<input type=checkbox name=hehe[]>csdn<br>
<input type=checkbox name=hehe[]>sina<br>
<input type=checkbox name=hehe[]>sohu<br>
<input type=submit name=ok>
</form>代码没有测试,可能有错~!
呵呵~!
if($ok){
while(list($key,$val)=each($hehe))
echo "$val<br>";
}
?>
<form action="" method=post>
<input type=checkbox name=hehe[]>csdn<br>
<input type=checkbox name=hehe[]>sina<br>
<input type=checkbox name=hehe[]>sohu<br>
<input type=submit name=ok>
</form>代码没有测试,可能有错~!
呵呵~!
if($ok){
while(list($key,$val)=each($hehe))
echo "$val<br>";
}
return;
?>
<form action="" method=post>
<input type=checkbox name=hehe[]>csdn<br>
<input type=checkbox name=hehe[]>sina<br>
<input type=checkbox name=hehe[]>sohu<br>
<input type=submit name=ok>
</form>这个应该正确~!
<input type=checkbox name=hehe[]>csdn<br>
<input type=checkbox name=hehe[]>sina<br>
<input type=checkbox name=hehe[]>sohu<br>
<input type=submit name=ok>
</form>
以上正确,在后台取hehe[0],hehe[1],hehe[2]的值即可
想每个数组都变成一个字符串;
如hehe1[0]==a;hehe1[1]==b;hehe2[1]==b;hehe2[2]==c;
.....
hehe50[0]==a;hehe50[1]==b;如何令$hehe1==ab;$hehe2==bc
.....
$hehe50==ab;
///不用连续join()50次吧!
<input type=checkbox name=hehe[]>csdn<br>
<input type=checkbox name=hehe[]>sina<br>
<input type=checkbox name=hehe[]>sohu<br>
<input type=submit name=ok>
</form>
以上正确,在后台取hehe[0],hehe[1],hehe[2]的值即可
回复人: scxy(小熊) (2001-11-17 13:39:11)
小熊,你是真懂假懂呀?别在这里混着骗人了,你那是什么逻辑呀???!!
笑死我了~~
真笨!
<?
if($ok){
while(list($key,$val)=each($hehe))
echo "$val<br>";
}
?>
<form action="" method=post>
<input type=checkbox name=hehe[]>csdn<br>
<input type=checkbox name=hehe[]>sina<br>
<input type=checkbox name=hehe[]>sohu<br>
<input type=submit name=ok>
</form>代码没有测试,可能有错~!
呵呵~!
——————————————————————————————————————
你是真懂假懂呀?别在这里混着骗人了,你那是什么逻辑呀???!!
笑死我了~~
真笨!
所以name要一个,value可以很多个~~
这样才能做出复选框~~
哎?
我对中国软件业越来越有信心了~~~~~
因为还有很多人在滥竽充数~~
呵呵~~
不要太早下结论,自己动手试一下。
file:///E:/delphi/try.htm?ok=ok
1
file:///E:/delphi/try.htm?hehe=on&ok=ok
12
file:///E:/delphi/try.htm?hehe=on&hehe=on&ok=ok
123
file:///E:/delphi/try.htm?hehe=on&hehe=on&hehe=on&ok=ok
13
file:///E:/delphi/try.htm?hehe=on&hehe=on&ok=ok
3
file:///E:/delphi/try.htm?hehe=on&ok=ok唉,太长时间没用php了,橙子鸟是对的。
5555555555555555
能看懂上面的结果,就知道我说的是什么意思了。
把form改成如下:
<form action="">
<input type=checkbox name=hehe>csdn<br>
<input type=checkbox name=hehe>sina<br>
<input type=checkbox name=hehe>sohu<br>
<input type=submit name=ok value="ok">
</form>
CSDN的同人们.. 救救我可以吗...
<input type=checkbox name=hehe value=csdn>csdn<br>
<input type=checkbox name=hehe value=sina>sina<br>
<input type=checkbox name=hehe value=sohu>sohu<br>
<input type=submit name=ok value="ok">
</form>这个仅仅是让你看看具体过程
实际上可以是<form action="">
<input type=checkbox name=hehe[0] value=csdn>csdn<br>
<input type=checkbox name=hehe[1] value=sina>sina<br>
<input type=checkbox name=hehe[2] value=sohu>sohu<br>
<input type=submit name=ok value="ok">
</form>接收那头用循环挨个收就是了
比如$sql = mysql_query("select id from tablenames");
while($row = mysql_fetch_array($sql)){
if(${checkbox.$row[id]}){
//在这插入数据库
}
}
create table multiple(name char(8),number int);
再插入初始值
insert into multiple values("php",0);
insert into multiple valuse("asp",0);
insert into multiple valuse("jsp",0);源程序如下:
<?
if(isset($lan))
{
?>
<html>
<head><title>处理多项选择框一例</title></head>
<body>
<?
$db=mysql_connect("localhost","","");
if($db==false){
print "对不起,现在无法链接数据库,请稍后再试。";
}
$res=mysql_select_db("test",$db);
if($res==false){
print "对不起,现在无法链接数据库,请稍后再试。";
}
for($i=0;$i<count($lan);$i++){
$query="select number from multiple where name='$lan[$i]';";
$res=mysql_query($query,$db);
if($res==false){ print "无法查询";}
$row=mysql_fetch_row($res);
if($row==false){
print "id $id doesn't exist.";
exit();
}
$counter=$row[0]+1;
$query="update multiple set number=$counter where name='$lan[$i]';";
$res=mysql_query($query,$db);
if($res==false){
print"update failed!";
exit();
}}
mysql_close($db);
?>
</body>
</html>
<?
}
else
{
?>
<html>
<head><title>处理多项选择框一例</title></head>
<body>
<form name="form1" method="post" action="">
<p>
<input type="checkbox" name="lan[]" value="php">
PHP<br>
<input type="checkbox" name="lan[]" value="asp">
ASP<br>
<input type="checkbox" name="lan[]" value="jsp">
JSP</p>
<input type="submit" value="完成">
</form>
</body>
</html> <?
}
?>
我想做php的人人都会.
这样你可以选择一个适合你的.
puke................