It might be confusing and a bit difficult. I have a $fcomm
variable that holds values as an array. This variable $fcomm
is then assigned to an 'echo div' into another foreach
loop. What I need is to make $fcomm
loop itself while it gets assigned and echoed with each <div>
. Here's the code...Thank you for any comments.
PHP:
for ($i2=0; $i2<$rowscheck; $i2++) {
//FRIEND QUERY COMMENTS
$fr_com = mysqli_query($connect,"SELECT * FROM comments WHERE name_main_id = '".$fcom[$i2]."' ORDER BY comm_id ASC ");
while ($rows_com = mysqli_fetch_array($fr_com)) {
extract($rows_com);
$fcomm[] = $rows_com['comment_main'];
}
}
if ($fr_check > 0 ) {
foreach ($friends_q2 as $fr_ids) {
$added_fr = "members/$fr_ids/userImg1.jpg";
if (!file_exists($added_fr)) {
$added_fr = "members/avatar/avatar.png" ;
}
echo "
<div id='frslide'>
<a href='javascript:window_usr($fr_ids)'>
<img src='".$added_fr."' height='68' width='66' hspace='2' vspace='16' id='fadd'/>
</a>
<span style='font-size:12px;position:relative;left:-71px;top:-1px;color:#ffffff; background-image:url(images/back_bar.png);'> ".$frnames2." </span>
</div>
<div id='frdiv' class='frdiv'>
<span style='font-size:12px;position:relative; left:-1px;top:72px;color:#ffffff;background-image:url(images/usr_main.png);'>
<a href='javascript:remusr($fr_ids)'>remove</a>
</span>
</div>
<div>".$fcomm;
}
}
$fcomm
variable holds strings of comments from SQL. So when I add $fcomm[$i]
or any loop variable to $fcomm
it yields just single letters from comments - all I need is to make $fcomm
print whole strings but different ones and the ones that correspond to proper each <div>
. When I tried to place $fcomm
in an inside loop - it prints strings but each string is the same...