Jump to content

Archived

This topic is now archived and is closed to further replies.

kevinritt

display mysql data on a web page in a table

Recommended Posts

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

Share this post


Link to post
Share on other sites
<?
  /*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>

Share this post


Link to post
Share on other sites
[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 ?> missing
also 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();

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.