Jump to content

Printing Results in a Simple Table


ArizonaJohn

Recommended Posts

Hello,

 

I have a MySQL table with a structure similar to this:

 

id1 id2 title url date

I would like to print out a simple table in PHP that with the following structure sorted in reverse chronological order for the most recent 10 entries (date above = date submitted) from the MySQL table:

 

title id2

How could I do this?

 

Thanks in advance,

 

John

Link to comment
https://forums.phpfreaks.com/topic/193427-printing-results-in-a-simple-table/
Share on other sites

 

<?php

//my sql connection goes here.

$sql = "select * from yourtablename";
$results = mysql_query($sql);

echo "<table><tr><th>title</th><th>id2</th></tr>";

while($row = mysql_fetch_array($results)){

<tr><td>$row['title']</td><td>$row['id2']</td></tr>;

}

echo "</table>";

?>

Archived

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

×
×
  • Create New...

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.