overlordofevil Posted April 4, 2008 Share Posted April 4, 2008 I am pulling data from a table and I want to place the info into a table and have the data come up in columns based on a variable pulled from the table. now I have the code pulling the data but I don't know how to put the data in to columns. here's what I got. <?php include ("misc.inc"); $query = "SELECT * FROM skill_info"; $result = mysql_query($query) or die(mysql_error()); echo "<br align='center'><h3>NERO Skills</h3>\n"; echo "<table border='1' cellspacing='15'>"; echo "<tr><td colspan='12'><hr></td></tr>"; echo "<tr><td>Trades and Crafts</td><td>Racial Abilities</td><td>Weapons and Armor</td><td>Scholarly Skills</td><td>Magic</td><td>Healing</td><td>Stealth Skills</td><td>Fighting Skills</td></tr>"; while ($row = mysql_fetch_array($result)) { echo "<tr>"; extract($row); if ($skillType = "Trades and Crafts") { echo "<td>$skillName</td>"; } elseif ($skillType = "Racial Abilities") { echo "<td>$skillName</td>"; } elseif ($skillType = "Weapons and Armor") { echo "<td>$skillName</td>"; } elseif ($skillType = "Scholarly Skills") { echo "<td>$skillName</td>"; } elseif ($skillType = "Magic Skills") { echo "<td>$skillName</td>"; } elseif ($skillType = "Healing Skills") { echo "<td>$skillName</td>"; } elseif ($skillType = "Stealth Skills") { echo "<td>$skillName</td>"; } elseif ($skillType = "Fighting Skills") { echo "<td>$skillName</td>"; } echo "</tr>\n"; } echo "<tr><td colspan='12'><hr></td></tr>\n"; echo "</table>\n"; ?> so what I tried is an if statement based on the skillType that is stored in the table and was trying to figure out how to line it up in the columns. any suggestions ? Link to comment https://forums.phpfreaks.com/topic/99472-organizing-data/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.