Runtheball Posted April 30, 2010 Share Posted April 30, 2010 As a PHP learning exercise, I'm trying to program a "star trek" game. The game allows a list of commands, which are executed through a switch statement. The command below (case 8 ) is to 'scan an enemy vessel'. It should pull enemy vessel info from a database and display it in a table. The table border is all that appears...nothing is inside - no table rows, no table data. case "8": global $enemyType; if ($con) { echo "Initiating scan, Captain."; echo "<br /><table class='tableData' width='66%' height='150px' cellpadding = '2'><tbody>"; $query = "SELECT * FROM rom_warbird"; $result = mysql_query($query) or die("Unable to retrieve scan data Sir"); while($row=mysql_fetch_array($result, MYSQL_ASSOC)) { $es1 = $row['0']; $es2 = $row['1']; $es3 = $row['2']; $es4 = $row['3']; $ews1 = $row['4']; $ews1Cond = $row['ews1Cond']; $ews1_stat = $row['ews1_stat']; $ee1 = $row['ee1']; $e_crew = $row['e_crew']; echo "<tr><td>$enemyType</td></tr>"; echo "<tr><td><hr></td></tr>"; echo "<tr><td>Shields at: " . $es1 . ", " . $es2 . ", " . $es3 . ", " . $es4 . "</td></tr>"; echo "<tr><td>Weapon Systems include " . $ews1 . " , at " . $ews1Cond . " and " . $ews1_stat . " . </td></tr>"; echo "<tr><td>Engines at " . $ee1 . " percent. </td></tr>"; echo "<tr><td>She has a crew of " . $e_crew . " remaining.</td></tr>"; } echo "</tbody></table><br />"; } break; The Firefox SGML parser reports "Error: end tag for "tbody" which is not finished" on the line of code where tbody first appears. According to the parser there are no table rows. In fact, nothing that I try to echo from within that while loop will actually echo. Echo statements inserted right up to the line before the while loop will echo. What am I doing wrong? Link to comment https://forums.phpfreaks.com/topic/200320-content-within-a-while-loop-isnt-echoing/ Share on other sites More sharing options...
ChemicalBliss Posted May 1, 2010 Share Posted May 1, 2010 I would highly reccommend starting with something a lot simpler for a learning exercise, starting this way could (and is) lead you into bad coding habits and database design. (You shouldnt have a table under the name of something you may later want to add, you should have references instead). To your error: I would imagine your html structure is not properly formatted before this code is called; Give us the HTML source output of your page. -cb- Link to comment https://forums.phpfreaks.com/topic/200320-content-within-a-while-loop-isnt-echoing/#findComment-1051313 Share on other sites More sharing options...
MidOhioIT Posted May 1, 2010 Share Posted May 1, 2010 In fact, nothing that I try to echo from within that while loop will actually echo Have you tried a simple echo like "hello world" or "inside while loop" How do you know for 100% certain that you are fetching rows from your query? Link to comment https://forums.phpfreaks.com/topic/200320-content-within-a-while-loop-isnt-echoing/#findComment-1051333 Share on other sites More sharing options...
liamthebof Posted May 1, 2010 Share Posted May 1, 2010 while($row=mysql_fetch_array($result, MYSQL_ASSOC)) { echo "Inside Loop"; print_r($row); } Try that inplace of the while loop to check your query ect. Link to comment https://forums.phpfreaks.com/topic/200320-content-within-a-while-loop-isnt-echoing/#findComment-1051477 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.