Of course it's possible
Though I think either me or svcghost have got the wrong end of the stick, I think you meant you want to insert data into two tables depending on certain information.
Essentially what you need to do is do all the processing before outputting the tables. Split data into two arrays, and THEN output the tables.
Pseudo:
PHP Code:
<?php
$Data = array(1 => 'One', 2 => 'Two', 3 => 'Three', 4 => 'Four');
$Table1 = array();
$Table2 = array();
foreach($Data as $Key => $Value){
if($Key % 2 != 0){
$Table1[$Key] = $Value;
}else{
$Table2[$Key] = $Value;
}
}
?>
<h2>Odd Numbers</h2>
<table>
<tr>
<th>Number</th>
<th>Name</th>
</tr>
<?php
foreach($Table1 as $Key => $Value){
echo '<tr><td>', $Key, '</td><td>', $Value, '</td></tr>';
}
?>
</table>
<h2>Even Numbers</h2>
<table> <!-- table 2 -->
<tr>
<th>Number</th>
<th>Name</th>
</tr>
<?php
foreach($Table2 as $Key => $Value){
echo '<tr><td>', $Key, '</td><td>', $Value, '</td></tr>';
}
?>
</table>
Bookmarks