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> 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);?> 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... 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);?> 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.... 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 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
Archived
This topic is now archived and is closed to further replies.