Ok this is my code ...
I want it to take the 5 newest entries on the table, but only the ones with a specific value in the 'section' column.
E.g. When you goto 'main.php?section=blue' it will get all the entries that have blue in their 'section' field.
$db = mysql_connect("localhost", "user", "password");
mysql_select_db("database",$db);
$result = mysql_query("SELECT * FROM table",$db);
$query = "SELECT id, message, section, date FROM table WHERE section='$_GET[section]' ORDER BY date DESC LIMIT 0, 5";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
if (mysql_num_rows($result) > 0) {
while($row = mysql_fetch_object($result)) {
echo "<tr><td>$row->id</td><td>$row->message</td><td>$row->section</td><tr>";
}
}
Thanks for any help that people can give, I would be very gratefull.
Bobby