need help with the output!
Posted: Thu Feb 12, 2009 8:42 pm
my code works perfectly fine by giving outputs of values by adding commas.
which for example will give an ouput like this:
but my problem now is if there's no data inside it with would always gives an ouput of
i need to eliminate this if there's no data inside to ouput.
thanks guys . . .
Code: Select all
<?php if ( $languages ) { ?>
<dl class="clearfix">
<dt>His spoken languages</dt>
<dd>
<?php
$string = '';
$i = 0;
$total = count($languages);
foreach ($languages as $value) {
$i++;
$string .= $value['language'];
if ( $i < $total ) { $string .= ', '; }
}
echo $string;
?>
</dd>
</dl>
<?php } ?>
Code: Select all
His spoken languages english, chinese, french
but my problem now is if there's no data inside it with would always gives an ouput of
Code: Select all
His spoken languages
thanks guys . . .