itsjames Posted May 13, 2009 Share Posted May 13, 2009 Hi there, My snippet of code below is supposed to present data from my MySQL database in a table. However, when the code is executed, I am presented with a totally blank page. while( $row = mysql_fetch_array( $runQuery ) { // determine if self collect is available if ( $row["selfcollect"] = 1 ) { $collect = "Yes" ; } else { $collect = "No" ; } // create the output $output = "<table width=\"450\" border=\"0\"><tr>"; $output .= "<td colspan=\"2\" class=\"resultTitle\">" . $row["name"] . "</td>"; $output .= "<td rowspan=\"3\" align=\"center\" width=\"110\" height=\"110\"><a href=\"#\" onclick=\"window.open('images/database/" . $row['image'] . ".jpg','Photo','width=600,height=550,scrollbars=yes')\"><img src=\"images/database/" . $row["image"] . ".jpg\" border=\"0\" /></a></td>"; $output .= "</tr><tr>"; $ouptut .= "<td width=\"170\"><p><strong>Category:</strong> " . $search . "</td>"; $output .= "<td width=\"170\"><strong>Dimensions:</strong> " . $row["dimensions"] . "<br />"; $output .= "<strong>Price:</strong> " . $row["price"] . "</td>"; $output .= "</tr><tr>"; $output .= "<td colspan=\"2\"><strong>Self collect available:</strong> " . $collect . "</td>"; $output .= "</tr><tr>"; $output .= "<td colspan=\"3\">" . $row["longdesc"] . "</td>"; $output .= "</tr></table>"; // display the output return $output; } Any ideas where I could be going wrong? Thanks Link to comment https://forums.phpfreaks.com/topic/157991-while-loop-not-returning-data-from-database/ Share on other sites More sharing options...
Ken2k7 Posted May 13, 2009 Share Posted May 13, 2009 while( $row = mysql_fetch_array( $runQuery ) Missing parenthesis. Link to comment https://forums.phpfreaks.com/topic/157991-while-loop-not-returning-data-from-database/#findComment-833354 Share on other sites More sharing options...
radi8 Posted May 13, 2009 Share Posted May 13, 2009 Well, that should generate a parse error when the page loads, but are you sure that the SQL is returning any data? Add a test to see and then display a message if no records returned: <?php if(mysql_num_rows($runquery)==0){ print 'OOPS! No data returned<br>'; } else{ while(....){} } ?> Link to comment https://forums.phpfreaks.com/topic/157991-while-loop-not-returning-data-from-database/#findComment-833361 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.