Hi,
I have a for loop, that i've tested and it works perfectly well, but when I put it in a function I get the message:
[] operator not supported for strings in these lines:
$headline[] = $row['headline'];
$story_id[] = $row['story_id'];
Any ideas how I can solve this?
PHP Code:$SQL = "SELECT headline, story_id from site ORDER BY story_id desc LIMIT 2";
$result = mysql_query($SQL) OR die(mysql_error());
$row = mysql_fetch_array($result);
$n = mysql_num_rows($result);
$active = ($active=='active' ? 'inactive' : 'active');
$inactive = ($inactive=='inactive' ? 'active' : 'inactive');
for ($i = 1; $i <= $n; $i++ ) {
$headline[] = $row['headline'];
$story_id[] = $row['story_id'];
echo '
<div id="leaderPanel'.$n=i.'" class="leadContainer" style="display:inline">
<a class="leader-'.$inactive.'"> '.$headline[0].' <br /> '.$story_id[0].'</a>
<a class="leader-'.$active.'">'.$headline[1].' <br /> '.$story_id[1].'</a>
</div>
';








Bookmarks