Posted by Samuel on 09/30/05 09:52
In your first example you'd have to sort the data with php, and in the
second you'd have to query the database once for each date you want to
show. I'd recommend this instead;
SELECT * FROM pictures ORDER BY date
You will be able to get all the data you need in only one query. The
script would basically look like this.
<?php
//Assuming you already opened and selected the db...
$query = "SELECT * FROM pictures ORDER BY date";
$result = mysql_query ($query);
while (($number_of_items < 30) && ($row = mysql_fetch_array($result)))
{
if ($last_date != $row['date'])
print_break_between_dates_or_whatever();
print_the_data_or_whatever($row);
$last_date = $row['date'];
$number_of_items++;
}
?>
Hope I helped and all =)
[Back to original message]
|