How do I design a mysql database layout that looks something like this
-------------------------------
|category#1
-------------------------------
|mysql field 1
|mysql field 2
|mysql field 3
-------------------------------
|category#2
-------------------------------
|mysql field 4
|mysql field 5
|mysql field 6
-------------------------------
Right now, my code is just capable of creating a table with category one and the database info under it. I want to be able to enter database information into different categories but don't know the actual PHP code for it.
PHP Code:
//----- database connection here $sql = "SELECT * FROM `weapons` ORDER BY name"; $result=mysql_query($sql) or die ('Error: '.mysql_error ());; $color="1"; echo '<table id="releases" align="center" cellspacing="0"> <tr background="/gfx/release_bg.jpg" align="left"><th>Name</th></tr>'; while($rows=mysql_fetch_array($result)){ if($color==1){ echo '<tr bgcolor="#2e0015" align="left"><td><img src="/gfx/spacer.png"> <a href="'.$rows["link"].'">'.$rows["name"].'</a></td>'; $color="2"; } else { echo '<tr bgcolor="#1f010f" align=left><td><img src="/gfx/spacer.png"> <a href="'.$rows["link"].'">'.$rows["name"].'</a></td>'; $color="1"; } } echo '</table>'; mysql_close(); ?>
What do I put after else to make another category like "animal" or "food" and then continue with two more echo of <tr>that have like $rows["age"] and $rows["year"]?
|