i would like to know how to retrieve information from a database table, and display it on a page in a table, split into the correct rows:
the MySQL table is layed out like:
ID:
Team1:
Team2:
it only has 3 rows.
i want to be able to display entries from this database in a table on a page, but it must only display the 5 latest entries into the database.
using print, i have the table drawn onscreen when the page is executed.
the table isnt much hehe, but only thing im interested in right now is getting it to display the results i need.
just to make it clear.
i have the table on the page with the names of the DB rows as headings, i want to display the 5 latest values from the database in the each of the rows below the headings.
The code for the entire page is:
Code: Select all
<?
include 'config.php';
$query = "SELECT id, team1, team2 FROM results";
$result = mysql_query($query);
if (!$result) {
die('Could not query:' . mysql_error());
}
{
print"<HTML><table width=\"200\" border=\"1\">
<tr>
<td>ID:<br></td>
<td>Team1:</td>
<td>Team2:</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table></html>";
}
?>im sorry if ive done everything completely wrong in the code above, but im completely new to PHP and have never used it before.
many thanks