foreach problem very strange...[RESOLVED]
Code...
PHP Code:
echo "<table>";
foreach($output as $val)
{
echo "<tr>";
echo "<td>";
echo $val;
echo "</td>";
echo "</tr>";
}
echo "</table>";
well i want each array value to be like this...in their own cell
Code:
<table>
<tr>
<td>
*value here*
</td>
</tr>
<tr>
<td>
*next value*
...
...
...so on
and with the code above it is supposed to do that!...guess what, It DOESNT!
it creates a new table a tr a td for each value so i end up having tons of tables :/
anyone knows what's wrong with it ?...
Thanks!
many thanks to visualad :) he corrected me...
THREAD RESOLVED!
Re: foreach problem very strange...
Can you post the exact ouput from the View Source in your browser?? There doesn't appear to be anything wrong with it. To make it more readable you should embed the PHP inside the HTML, not the other way round:
PHP Code:
?>
<table>
<?php foreach($output as $val): ?>
<tr>
<td><?php echo($val) ?></td>
</tr>
<?php endforeach; ?>
</table>
Re: foreach problem very strange...
Quote:
<table><tr><td>TXT</td></tr><tr><td>TXT2</td></tr></table>
<table><tr><td>txt3</td></tr><tr><td>txt4</td></tr></table>
and so on...
also tried this...
Quote:
echo "<table>";
foreach($output as $val)
{
echo "<tr><td>".htmlspecialchars($val)."</td></tr>";
}
echo "</table>";
nothing...