Re: Breaking apart by group?
| From: | _lallous | Date: | Fri, 12 Oct 2001 08:36:54 +0000 |
| Subject: | Re: Breaking apart by group? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-70894@lists.php.net to get a copy of this message | ||
i think I get you...the idea that i got seems to translate to this:
$result = mysql_query("SELECT * FROM tablename ORDER BY publishday");
$lastpublish = '';
while ($r= mysql_fetch_array($result))
{
if ($lastpublish != $r['publishday'])
{
if ($lastpublish != '')
echo '</table>'; // close previous table
echo "<table>";
}
echo
"<tr><td>{$r['name']</td><td>{$r['publishday']</td></tr>";
// etc
etc.....
$lastpublish = $r['publishday'];
}
if (!empty($lastpublish))
echo '</table>';
this will open a new table open each new publish day, and will close the
last table tag correctly.
this is an untested code...hope it helps
"Jeff Lewis" <jeff@hyrum.net> wrote in message
news:004d01c15281$2e8ee4e0$76a1a8c0@LEWISJCIT...
I am looping through a set of data retrieved through my database and I want
to break it apart based on the variable called publishday. So the first
time around a new table will need to be started but for each time around I
need to check if a new publishday is encountered. If so, close the previous
table and start a new one.
If anyone understands and can help out, I'd be very appreciative :)
Jeff