Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6716625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:45:21+00:00 2026-05-26T08:45:21+00:00

It might be confusing and a bit difficult. I have a $fcomm variable that

  • 0

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);'>&nbsp;".$frnames2."&nbsp;</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);'>
    &nbsp;<a href='javascript:remusr($fr_ids)'>remove</a>&nbsp;
  </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…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:45:21+00:00Added an answer on May 26, 2026 at 8:45 am

    You need to increase the index you’re trying to retrieve from the fcomm array. Note the changes using $j variable.

    if ($fr_check > 0 ) { 
      $j=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);'>&nbsp;".$frnames2."&nbsp;</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);'>
        &nbsp;<a href='javascript:remusr($fr_ids)'>remove</a>&nbsp;
      </span>
    </div>
    <div>".$fcomm[$j];  
        $j++;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Bear with me—this might be a bit confusing! I have a javascript that adds
the question might be a bit confusing :) i have this json: [ {media_path:2.jpg,type:1,complete:1},
Ok this might be a bit confusing, but here goes. Let's say I have
Title might be a bit confusing, so let me explain. I have a website
the title might be a little bit confusing, let me explain, ;) I have
OK, this might sound a bit confusing and complicated, so bear with me. We've
the question might be a bit confusing, so here is what i have: i
The question might be a little bit confusing. I have an inline div and
This one might be a little confusing. I'm using AMCharts with rails. Amcharts comes
This might be a bit on the silly side of things but I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.