我有這個代碼,我想防止表頭重複。 有人可以幫忙嗎?本網站要求我提供更多細節,然後才能發佈此問題。表頭在while循環中重複
if (isset($_POST['toys'])) {
$query = 'SELECT * FROM `toys` WHERE size = ?';
$sth = $db->prepare($query);
foreach($_POST['toys'] as $each_check) {
if(! $sth->execute(array($each_check))) {
die('MySQL Error: ' . var_export($sth->error_info(), TRUE));
}
echo "<table>";
echo "<tr>
<th>ratio</th>
<th>size</th>
<th>built</th>
<th>description</th>
</tr>";
while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
echo "<tr><td>" . $row['ratio'] .
"</td><td>" . $row['size'] .
"</td><td>" . $row['built'] .
"</td><td>" . $row['description'] .
"</td></tr>";
}
echo "</table>";
}
}
坦克
非常感謝你親愛的人! – Paco