I've been working on a project that prints sql data into a table. Recently, I've come into a problem with the table. What this code should do is output a table of results from a MySQL query but all it's outputting is something like:
Item1 Item1
For some reason it leaves all the other fields blank. Here's my code:
$table = "<table class='TestTable'><tr class='tr'>";
while($row = mysql_fetch_assoc($result)){
$table .= "<th class='th'>";
$table .= $row['NameOfItem'];
$table .= "</th>";
}
$table .= "</tr><tr class='tr'>";
while ($row = mysql_fetch_assoc($result)){
$table .= "
<td class='td'>Minimum Bid: <b>";
$table .= $row['MinBid'];
$table .= "</b></td>";
}
$table .= "</tr><tr class='tr'>";
while ($row = mysql_fetch_assoc($result)){
$table .= "<td class='td'>Current Bid: <b>";
$table .= $row['CurrentBid'];
$table .= "</b></td>";
}
$table .= "</tr><tr class='tr'>";
while ($row = mysql_fetch_assoc($result)){
$table .= "<td class='td'>Sold By: <b>";
$table .= $row['SoldBy'];
$table .= "</b></td>";
}
$table .= "</tr><tr class='tr'>";
while ($row = mysql_fetch_assoc($result)){
$table .= "<td class='td'>Time Left: <b>";
$table .= printf('%d days, %d hours, %d minutes left', $diff->d, $diff->h, $diff->i);
$table .= "</b></td>";
}
$table .= "</tr></table>";
echo $table;
When I view source I get:
<table class='TestTable'>
<tr class='tr'>
<th class='th'>Item1</th>
<th class='th'>Item1</th>
</tr>
<tr class='tr'></tr>
<tr class='tr'></tr>
<tr class='tr'></tr>
<tr class='tr'></tr>
</table>