Re: Breaking apart by group?
| From: | David Robley | Date: | Fri, 12 Oct 2001 00:26:25 +0000 |
| Subject: | Re: Breaking apart by group? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-70865@lists.php.net to get a copy of this message | ||
On Fri, 12 Oct 2001 04:08, Jeff Lewis wrote:
> Yep I have ORDER BY publishday which works fine but am having trouble
> with the logic to get the tables to print correctly. So far they are
> printing off one day :) So Wednesdays events are showing under
> Thursday :)
>
> Jeff
> ----- Original Message -----
> From: "Alfredeen, Johan" <johanalfredeen@vp.net>
> To: "'Jeff Lewis'" <jeff@hyrum.net>;
> <php-general@lists.php.net>
> Sent: Thursday, October 11, 2001 2:41 PM
> Subject: RE: [PHP] Breaking apart by group?
>
> > Sounds like you need to SORT on publishday, then compare the current
> > value to the previous one you have stored in a variable
> > $prev_publishday.
> >
> > Johan
> > which world? www.pongworld.com
> >
> >
> > -----Original Message-----
> > From: Jeff Lewis [mailto:jeff@hyrum.net]
> > Sent: Thursday, October 11, 2001 12:19 PM
> > To: php-general@lists.php.net
> > Subject: [PHP] Breaking apart by group?
> >
> >
> > 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
It's easier to follow the thread of a discussion if you put your reply at
the bottom :-)
What you need to do is something like:
$conn = mysql_connect(blah);
$result = mysql_query($queery, $conn);
$oldpday = '';
while($row = mysql_fetch_array($result) { // Or whatever loop you use
extract($row);
if($oldpday == $publishday) {
//Start new table
}
// Do display stuff
$oldpday = $publishday;
}
--
David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA
Bugs are Sons of Glitches!