demiurgen
10-29-2006, 02:02 PM
how can i get this foreach to break after 2 runs??
so that it output only 2 td tags inside the one row...
<tr>
foreach ($RECORDS as $record){
echo "<td>";
echo $record->getField("heading");
echo "</td>";
}
</tr>
AmazingAnt
10-29-2006, 02:35 PM
First, Don't forget the php tags. The PHP won't work inside standard HTML.
Second, if you want it to keep going on a new line afterwards, try this:
<tr>
<?php
$number = 0;
foreach ($RECORDS as $record){
if ($number != 2){
echo "<td>";
echo $record->getField("heading");
echo "</td>";
$number = $number + 1;
} else {
echo "</tr>\n<tr><td>";
echo $record->getField("heading");
echo "</td>";
$number = 1;
}
} ?>
</tr>
I don't use tables much, so I'm not positive that this will work, but it's there.
This way, it will close the table row tag and start a new one every time it puts two pieces of table data in.
Good?
If ($good != "yes"){
echo "darn";
} else {
echo "Yay";
}