Re: rows by day
| From: | Sebastian | Date: | Mon, 16 Jun 2003 04:34:38 +0000 |
| Subject: | Re: rows by day | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-151628@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: "John W. Holmes"
| John W. Holmes wrote:
|
| You only need one query. One of your columns should be what you want to
| "change" on, like DAYOFWEEK(date_column). As you loop through your rows,
| you echo out your "heading" whenever this column changes...
|
| while($row = mysql_fetch_assoc($result))
| {
| if($row['dayofweek_column'] != $old_dayofweek)
| {
| echo "<tr><th>{$row['dayofweek_column']}'s
Columns</th></tr>";
| $old_dayofweek = $row['dayofweek_column'];
| }
| echo "$row[title] <br/> Written by $row[author] <br/> $row[text]";
| }
|
| Untested, but something like that. :)
--
John W. Holmes, Thank you greatly!
With some modifications I got it to work, thanks for pointing me in the
right direction!
.. and yes you were right about the fetch_row, it was a typo.
$result = $db->sql("SELECT * FROM $news GROUP BY time DESC LIMIT
$_GET[page], $pagelimit");
while($row = mysql_fetch_array($result)) {
$content[timedate] = date("l",$row['time']);
$newsfor = "";
if($content[timedate] != $old_dayofweek)
{
$newsfor = "<span class=\"newsdate\">News for
$content['datefor']</span> <br/>";
$old_dayofweek = $content[timedate];
}
echo "$newsfor $row[title] <br/> Written by $row[author] <br/> $row[text]";
}
cheers,
- Sebastian