试图用基于复选框输入的数据回显多行。从当前代码开始,无论勾选多少个复选框,它都只处理一个复选框中的数据。请帮忙!
while ($row = mysql_fetch_assoc($r)) {
$pals .= '<input type="checkbox" name="pal_num[]" value="'
. $row['pal_num'] . '">' . $row['pal_num'] . '<br>';
}
if ($pal == '') {
echo '';
} else {
echo '<form name="get_pal" action="post2.php" method="POST">';
echo $pals;
echo '<input type="submit" name="post" value="Go!">';
echo '</form>';
}
post2.php:
$w = $_POST['pal_num'];
$rrr = mysql_query("SELECT * FROM pl_tab WHERE pal_num" . $w[0]);
while ($row = mysql_fetch_array($rrr)) {
echo '<tr><td>' . ' ' . '</td>';
echo '<td rowspan="5">' . $row['descr'] . '</td>';
echo '<td><b>' . 'Total weight' . '<b></td>';
echo '<td>' . ' ' . '</td><td>' . ' ' . '</td></tr>';
echo '<td>' . ' ' . '</td>';
echo '<td colspan="3">' . ' ' . '</td>';
//this part should multiple based on how many checkboxes are ticked.
echo '<tr><td>' . $row['l_num'] . '</td>';
echo '<td>' . $row['pal_num'] . '</td>';
echo '<td>' . $row['weight 1'] . '</td><td>' . $row['weight 2'] . '</td></tr>';
}
echo "</table>";
}
答案 0 :(得分:1)
可能会有效:
$w = "'".implode("','",$_POST['pal_num'])."'";
$rrr = mysql_query("SELECT * FROM pl_tab WHERE pal_num in (".$w.");");
...可能您忘记了echo "<table>";
之前的while
:)