I've got a mysql query using pdo, the issue is the data won't line up in a table. Any suggestions? I would like it to look like a standard html table or something. I'm open to any suggestions.
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
}
If you generate the HTML properly things will work better.
So think before you code
echo "<table width='900'>";
foreach($results as $row) {
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>';
//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
}
echo "</table>";