kevinritt Posted October 16, 2006 Share Posted October 16, 2006 Hi,I recently received some great help from these forums on how to enter homework on a school's website. I tried displaying the data on a webpage in a table but it does not work. Can anyone point me to a tutorial or show me how to display a table using php? ;D Link to comment https://forums.phpfreaks.com/topic/24080-display-mysql-data-on-a-web-page-in-a-table/ Share on other sites More sharing options...
dymon Posted October 16, 2006 Share Posted October 16, 2006 <? /*DB Connection*/ /*DB Query & Result*/?><table border="0"> <?whilt $row=mysql_fetch_array($query_result) { print "<tr>"; print "<td>".$row['field_name']."</td>"; print "<td>".$row['field_name2']."</td>"; print "<td>".$row['field_name3']."</td>"; ..................................................... print "<tr>";</table> Link to comment https://forums.phpfreaks.com/topic/24080-display-mysql-data-on-a-web-page-in-a-table/#findComment-109446 Share on other sites More sharing options...
kevinritt Posted October 16, 2006 Author Share Posted October 16, 2006 [quote author=dymon link=topic=111636.msg452528#msg452528 date=1160998355]<? /*DB Connection*/ /*DB Query & Result*/?><table border="0"> <?whilt $row=mysql_fetch_array($query_result) { print "<tr>"; print "<td>".$row['field_name']."</td>"; print "<td>".$row['field_name2']."</td>"; print "<td>".$row['field_name3']."</td>"; ..................................................... print "<tr>";</table>[/quote]Is there a closing ?> missingalso I am only pulling the latest entry from the database so I would not need the fetch_array. Is that correct? I am using the SELECT LAST_INSERT_ID(); Link to comment https://forums.phpfreaks.com/topic/24080-display-mysql-data-on-a-web-page-in-a-table/#findComment-109500 Share on other sites More sharing options...
dymon Posted October 16, 2006 Share Posted October 16, 2006 Yes there should be ?> after print ...;If you want to extract the last entry, you can use:[code] mysql_query("SET NOCOUNT ON", $conn); $result = mysql_query("SELECT @"."@IDENTITY AS Ident", $conn); $row = mysql_fetch_row($result);[/code]This code worked for me, and in the $row are all the fields and values for the last entry. Link to comment https://forums.phpfreaks.com/topic/24080-display-mysql-data-on-a-web-page-in-a-table/#findComment-109509 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.