我创建了一个动态复选框,但未能在另一个页面上显示其值。我所做的工作如下:
索引.php
<form method="post" action="print.php">
<?php
$host="localhost";
$username="root";
$password="";
$database="checkbox";
mysql_connect($host,$username,$password);
mysql_select_db("$database");
//Create the query
$sql = "select test, rate FROM lab";
$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_assoc($result)) {
echo <<<EOL
<input type="checkbox" name="name[]"value="$row['test']}/{$row['rate']}"/>
{$row['test']}-{$row['rate']}<br />
EOL;
}
?>
<br>
<input type="submit" name="submit" value="Add" />
</form>
我正在尝试在名为 print.php 的第二个页面上显示该值:
<?php
print $_POST['name'];
?>