Not sure how to loop this...(Newbie)
| From: | webmaster at tececo dot com | Date: | Sat, 01 Jun 2002 06:22:03 +0000 |
| Subject: | Not sure how to loop this...(Newbie) | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-100207@lists.php.net to get a copy of this message | ||
I have this code:
$end_date = time();
$year = 2002;
$month = 4;
$monthi = $month + 1;
$time = SecondsInMonth($month, $year);
$time_i = SecondsInMonth($monthi, $year);
$query = "SELECT * FROM news WHERE date < $time_i AND date > $time ORDER BY id";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo '<tr><td><h3>';
echo date('F', mktime(12, 0, 0, ++$month));
echo '</h3></td>';
echo '<td>';
for ($i=0; $i < $num_results; $i++)
{
$row = mysql_fetch_array($result);
echo '<a href="news_temp.php?id=';
echo $row['id'];
echo '">: ';
echo $row['title'];
if(!$row['date'] == 0){
echo ' - ';
echo date("d-M-y", $row['date']);
}
echo ' :</a><br>';
}
echo '</td></tr>';
if($month == 12){
$year++;
$month = 0;
}
And I am not sure how to loop it.
It Currently prints like this:
May : A Carbon Based Built Environment? - 21-May-02 :
I am not sure how to get the newest records to display at the top. Rather than the bottom. There is
no looping yet as I am not sure how to do it. Can I reverse to results array or something? Every
month is in a new set of cells.
Thanks,
JJ Harrison
webmaster@tececo.com
www.tececo.com