MasterACE14 Posted September 16, 2007 Share Posted September 16, 2007 For some reason my array elements are on the outside of my table, http://www.crikeygames.com.au/conflictingforces/index.php?page=encyclopedia can someone tell me why? heres the code: <?php // encyclopedia /* includes */ include '/home/ace/public_html/conflictingforces/weapons.php'; ?> <div id = "encyclopedia"> <center><b><u>Encyclopedia</u></b><br></center> <center> <?php /* Grab weapon Array and Display it */ echo "<h1>Using foreach loop to display elements</h1>"; for ($row = 0; $row < 3; $row++) { echo "<table class=\"fix\">"; echo "<tr><td colspan='2'>Weapon</td></tr>"; foreach($weapons[$row] as $key => $value) { echo "<td>"; echo "<tr>".$key."</tr>"; echo "</td>"; echo "<td>"; echo "<tr>".$value."</tr>"; echo "</td>"; } } echo "</table>"; ?> </center> </div> Regards ACE Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 16, 2007 Share Posted September 16, 2007 You have tr and td backwards. This is an HTML, not a PHP question. tr means table row. td is a table cell. you don't put a row inside a cell. Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted September 16, 2007 Author Share Posted September 16, 2007 LOL, how could I get that wrong? lol, Thanks jesirose, now im down to 1 problem, the names and values are all in 1 column, instead of 2 columns. :-\ Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted September 16, 2007 Author Share Posted September 16, 2007 . Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 16, 2007 Share Posted September 16, 2007 Because you have new cell rows each time. Remove the closing and opening trs between your values... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.