我有一個使用pdo的mysql查詢,問題是數據不會在表中排隊。有什麼建議麼?我希望它看起來像一個標準的HTML表或其他東西。我願意接受任何建議。從PDO格式化數據Mysql查詢
foreach($results as $row) {
echo "<table width='900'>";
echo "<tr>";
echo "<td>";
echo htmlspecialchars($row['serial']) . "</td>";
echo "<td>";
echo htmlspecialchars($row['model']) . "</td>";
echo "<td>";
echo htmlspecialchars($row['deviceCondition']) . "</td>";
echo "<td>";
echo htmlspecialchars($row['sealCondition']) . "</td>";
echo "<td>";
echo htmlspecialchars($row['location']) . "</td>";
echo "<td>";
echo htmlspecialchars($row['deployDate']) . "</td>";
echo "<td>";
echo htmlspecialchars($row['weight']) . "</td>";
echo "<td>";
echo htmlspecialchars($row['notes']) . "</td>";
echo "</tr>";
echo "</table>";
//Arrays
$serials [] = htmlspecialchars($row['serial']); //serial as an array
$models [] = htmlspecialchars($row['model']); //model as an array
$deviceConditions [] = htmlspecialchars($row['deviceCondition']);//deviceCondition as an array
$locations [] = htmlspecialchars($row['location']); //location as an array
$deployDates [] = htmlspecialchars($row['deployDate']); //deployDate as an array
$weights [] = htmlspecialchars($row['weight']); //weight as an array
$notess [] = htmlspecialchars($row['notes']); //notes as an array
}
地方你'
有時你想知道爲什麼你會打擾 – RiggsFolly
分配給數組時不要使用'htmlspecialchars'。這應該只在網頁上顯示時使用。 – Barmar