Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

End table or row in loop

Status
Not open for further replies.

buzzt

Programmer
Oct 17, 2002
171
CA
I need to tell php to either end the table, or just write a new row in the table based on the date in the next row of my MySQL query. So basically, if the date from the row in the next result is the same as the date in the previous result, I would write a new row for the result and not re-write the date. If the date was different, I would write the new date and start a new table.

example:

08-29-2003
result 1 result 1
result 2 result 2

08-30-2003
result 3 result 3

08-31-2003
result 4 result 4

 
Are the date tables predefined? Or are you writing them as they are encountered?

·genoa

If a dog craps in the yard and buries it, is that considered steganography?
 
Nevermind. I'm just tired. I didn't quite get your message at first.

·genoa

If a dog craps in the yard and buries it, is that considered steganography?
 
What does your code look like thus far?

·genoa

If a dog craps in the yard and buries it, is that considered steganography?
 
Here is the loop in question:


for ($i=0; $i<$num_results; $i++)
{
if ($i % 2)
{
$row_color=&quot;#FFFFFF&quot;;
}
else
{
$row_color=&quot;#EEEEEE&quot;;
}

$row = mysql_fetch_array($query);
$title = $row[title];
$start = $row[start];
$date = $row[date];
$desc = $row[description];

$thisdate=explode(&quot;-&quot;, $date);
$thisdate=date (&quot;l, F d, Y&quot;, mktime(0,0,0,$thisdate[1],$thisdate[2],$thisdate[0]));

echo &quot;<strong>&quot; . $thisdate. &quot;</strong><br><img src=\&quot;../graphics/filler.gif\&quot; width=1 height=3><br>&quot;;
echo &quot;<table width=530 border=0 cellspacing=0 cellpadding=0>&quot;;
echo &quot;<tr>&quot;;
echo &quot;<td colspan=3 height=1 valign=top class=\&quot;text\&quot; bgcolor=\&quot;red\&quot;><img src=\&quot;../graphics/filler.gif\&quot; width=15 height=1&quot;;
echo &quot;</tr>&quot;;
echo &quot;<tr height=20>&quot;;
echo &quot;<td width=35 class=\&quot;text\&quot; bgcolor=\&quot;&quot; . $row_color . &quot;\&quot;>&quot; . $start . &quot;</td>&quot;;
echo &quot;<td width=225 class=\&quot;text\&quot; bgcolor=\&quot;&quot; . $row_color . &quot;\&quot;>     &quot; . $title . &quot;</td>&quot;;
echo &quot;<td width=270 class=\&quot;text\&quot; bgcolor=\&quot;&quot; . $row_color . &quot;\&quot;>&quot; . $desc . &quot;</td>&quot;;
echo &quot;</tr>&quot;;
#### THIS IS WHERE THE TABLE OR ROW WOULD HAVE TO VARY - CURRENTLY, A NEW TABLE IS WRITTEN EACH TIME ###
echo &quot;<tr>&quot;;
echo &quot;<td colspan=3 height=1 valign=top class=\&quot;text\&quot; bgcolor=\&quot;red\&quot;><img src=\&quot;../graphics/filler.gif\&quot; width=15 height=1&quot;;
echo &quot;</tr>&quot;;
echo &quot;</table>&quot;;
echo &quot;<br>&quot;;

}
 
Your best bet is just to order the mysql query by date. Otherwise you'll have to place all the entries into an array.

·genoa

If a dog craps in the yard and buries it, is that considered steganography?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top