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 Link to comment https://forums.phpfreaks.com/topic/69537-solved-array-values-outside-of-the-table/ 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. Link to comment https://forums.phpfreaks.com/topic/69537-solved-array-values-outside-of-the-table/#findComment-349416 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. :-\ Link to comment https://forums.phpfreaks.com/topic/69537-solved-array-values-outside-of-the-table/#findComment-349425 Share on other sites More sharing options...
MasterACE14 Posted September 16, 2007 Author Share Posted September 16, 2007 . Link to comment https://forums.phpfreaks.com/topic/69537-solved-array-values-outside-of-the-table/#findComment-349441 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... Link to comment https://forums.phpfreaks.com/topic/69537-solved-array-values-outside-of-the-table/#findComment-349614 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.