yanti Posted July 23, 2009 Share Posted July 23, 2009 pls check on this code....it doesnt display any data from database... <?php include('/include/dbConnection.php'); $result = mysql_query("SELECT * FROM ucapan ORDER BY datetime"); while($row = mysql_fetch_array($result)) ?> <tr> <td><?php echo $row['id'] ?> </td> <td><?php echo $row['datetime'] ?> </td> <td><?php echo $row['ucapan'] ?> </td> <td><?php echo $row['sender'] ?> </td> </tr> </table> <? mysql_close($con);?> this is code to display below is code for html table <body> <table width="100%" border="1" class="InternalHeader"> <tr> <td>LIST OF SMS UCAPAN</td> <td> </td> </tr> </table> <p> </p> <table width="100%" border="1" class="NormalTableTwo"> <tr> <td>NO</td> <td>DATE TIME</td> <td>UCAPAN</td> <td>SENDER</td> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/167084-display-database-in-html-table/ Share on other sites More sharing options...
dzelenika Posted July 23, 2009 Share Posted July 23, 2009 You should use braces around looping part: <?php include('/include/dbConnection.php'); $result = mysql_query("SELECT * FROM ucapan ORDER BY datetime"); while($row = mysql_fetch_array($result)) { // <------------- ?> <tr> <td><?php echo $row['id'] ?> </td> <td><?php echo $row['datetime'] ?> </td> <td><?php echo $row['ucapan'] ?> </td> <td><?php echo $row['sender'] ?> </td> </tr> </table> <?php } // <------------- mysql_close($con);?> Quote Link to comment https://forums.phpfreaks.com/topic/167084-display-database-in-html-table/#findComment-880992 Share on other sites More sharing options...
yanti Posted July 23, 2009 Author Share Posted July 23, 2009 ok...i changed it....but still no result display... Quote Link to comment https://forums.phpfreaks.com/topic/167084-display-database-in-html-table/#findComment-880995 Share on other sites More sharing options...
dzelenika Posted July 23, 2009 Share Posted July 23, 2009 Then check is your query gives any result at all: <?php include('/include/dbConnection.php'); if($result = mysql_query("SELECT * FROM ucapan ORDER BY datetime")) { while($row = mysql_fetch_array($result)) { ?> <tr> <td><?php echo $row['id'] ?> </td> <td><?php echo $row['datetime'] ?> </td> <td><?php echo $row['ucapan'] ?> </td> <td><?php echo $row['sender'] ?> </td> </tr> </table> <?php } // <------------- } else { echo "error"; } mysql_close($con);?> Quote Link to comment https://forums.phpfreaks.com/topic/167084-display-database-in-html-table/#findComment-880997 Share on other sites More sharing options...
yanti Posted July 23, 2009 Author Share Posted July 23, 2009 ok..the result gives an error.... Quote Link to comment https://forums.phpfreaks.com/topic/167084-display-database-in-html-table/#findComment-881000 Share on other sites More sharing options...
dzelenika Posted July 23, 2009 Share Posted July 23, 2009 ok..the result gives an error.... use echo mysql_error(); to find out which error Quote Link to comment https://forums.phpfreaks.com/topic/167084-display-database-in-html-table/#findComment-881009 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.