这个是test1.php
<html>
<head>
<title>
</title>
</head>
<body>
<?php
$connect=mysql_connect("localhost","root","123456");
$select=mysql_select_db("music");
$query="select * from test";
$result=mysql_query($query);
while($row=mysql_fetch_array($result))
{
extract($row);
echo" <form name=form method=post action=test2.php>";
echo" <input type=checkbox name=".$id."/>".$name."<br />";}
?><input type="submit" name="submit" value="提交" /></form>
</body>
</html>表test中的内容是id         name
1         basketball
2         football
3         tennis如果选择的是tennis,请问要在test2.php中显示  id的值,程序该怎么写?
我这样写错在哪里?
<?php@extract($_POST);
echo $id;
?>

解决方案 »

  1.   

    echo" <input type=\"checkbox\" name=\"name[]\" value=\"".$id."\"/>".$name."<br />";
    php:
    print_r($_POST['name']);
      

  2.   

    我问的不对,其实是如果在test1.php中选择了football 在test2.php中如何确定它?
      

  3.   

    这么说吧,如果选择了football,要在test2.php中显示出来,怎么写啊?
      

  4.   

    echo" <input type=checkbox name=".$id."/>".$name."<br />";//这句要改一下。。//改成echo" <input type=checkbox name=\"types[]\" value==".$id." />".$name."<br />";
    //name要用数组的形式
    在另一个页面就可以用$_POST['types']      来获取
      

  5.   

    我还是写不出来,刚才还显示了一个毫无关系的词,film
    请哪位高手给我一个完整的程序
      

  6.   

    test1.php只是循环定义了3个复选框的name,value值并没有给出来,所以在test2.php中肯定接收不到value了!