georegjlee Posted March 22, 2007 Share Posted March 22, 2007 Hi, I ran this code and all I get is 1 row displayed containing the text and checkbox but none of the database data. <html> <head> <title>TEST</title> </head> <body> <?php //connection to the database $dbhandle = mysql_connect("localhost", "root", "") or die("Couldn't connect to SQL Server on $myServer"); //select a database to work with $selected = mysql_select_db("waterways", $dbhandle) or die("Couldn't open database myDB"); if (isset($_POST['submit'])) { // I put the code I need to delete the the records in here so. // When I press the submit the first time do I just leave the form action blank to reload the page. } else{ $query = "SELECT * FROM pending_problems"; $result = mysql_query($query, $dbhandle); $table_block = " "; while ($row = mysql_fetch_array($result)); { $id = $row['problem_id']; $description = $row['problem_desc']; $name = $row['member_id']; $ww_id = $row['waterway_id']; $severity = $row['problem_severity']; $table_block .= "<tr><td>$id</td><td>$ww_id</td><td>$description</td><td>$severity</td><td>$name</td><td>Check box to delete</td><td><td><p><input type=\"checkbox\" name = \"id_array[]\" value = \"$id\"></p></td></tr>"; } print ("<h3 style = \"color: blue\"> Problems Table</h3>"); print ("<form id=\"form1\" name=\"form1\" method=\"post\">"); print ("<table border = \"1\" cellpadding = \"3\" cellspacing = \"2\">"); print ("$table_block"); print ("</table>"); print ("<input type=\"submit\" value = \"Update Problems\" >"); print ("</form>"); } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/43824-blank-table/ Share on other sites More sharing options...
Orio Posted March 22, 2007 Share Posted March 22, 2007 I can't see a opening table tag. Orio. Link to comment https://forums.phpfreaks.com/topic/43824-blank-table/#findComment-212736 Share on other sites More sharing options...
trq Posted March 22, 2007 Share Posted March 22, 2007 You never check your query actually works before trying to use it. The general syntax for a select query is.... <?php // connect $sql = "SELECT bar FROM foo"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { // display data. } else { // no records found. } else { // query failed. } ?> Link to comment https://forums.phpfreaks.com/topic/43824-blank-table/#findComment-212737 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.