Hi guys,
I have a page that generates tables from a MySQL database. Each table is separated by seriesTitle.
For better visualization:
http://www.supermandatabase.com/actionFigures/actionfigures.php
Now if you look at the first table on that page you'll see the table header says "DC SUPER HEROES : SERIES 2" and then lists 9 action figures. The only thing is... Lex Luthor should get his own new table because he is in series 4, not series 2.
Here is the code I am using to generate the tables:
<?php
$sql = mysql_query("SELECT *
FROM actionFigures
ORDER BY seriesTitle, title ASC") or die (mysql_error());
$current = '';
while($row = mysql_fetch_array($sql)) {
if($current != $row['seriesTitle']) {
$current = $row['seriesTitle'];
echo "<table width='630' border='0' bgcolor=#253b5a cellpadding='3' cellspacing='1'>
<tr>
<td width='530'><font color=#ffffff><b>" . strtoupper($current) . " : SERIES " . $row['series'] . "</b></font></td>
<td width='100'<font color=#ffffff><b>YEAR</b></font></td>
</tr><br>";
}
//Continuation of CSS for the Alternating Color Rows
$class = $class == 'even' ? 'odd' : 'even';
//Populate the Tables from the Database
echo "<tr class=\"$class\">\n";
echo "<td><a href='view_actionfigures.php?id=" . $row['actionFigureId'] . "'>" . $row['title'] . "</a></td>\n";
echo "<td>$row[year]</td>\n";
echo "</tr>\n";
}
echo "</table>";
echo "<br>";
?>
I see that the echoed table is echoing anything with the same seriesTitle into the same table. How do I get it so it echoes the same seriesTitle and also the series so Lex Luthor will have his own table?
Thanks for the help and advice.
SC