External looping of the variable
<p>How could I best loop the data through a variable that's nested inside a 'while' loop but it's called outside of it ? Like in this example:</p>

<p>PHP:</p>

<pre><code> $fr_q2 = mysqli_query($connect,"SELECT * FROM friends WHERE username ='".$_SESSION['user']."'   
 ORDER BY id DESC");
 while ($rowsPicFr2 = mysqli_fetch_array($fr_q2)) {

 $friends_q2[] = $rowsPicFr2['added_friend'];
 $frn[] = $rowsPicFr2['added_friend'];
 $frn2 = $rowsPicFr2['added_friend'];
 }

 $rowscheck = mysqli_num_rows($fr_q2);
 for ($i=0; $i&lt;$rowscheck; $i++)
</code></pre>

<p>HTML:</p>

<pre><code> &lt;a href="#" onclick="remdata(&lt;?php echo $frn[$i]; ?&gt;)"&gt;YES&lt;/a&gt;
</code></pre>

<p>So I need to pass $frn[$i] into a remdata() function - but the $frn[$i] needs to loop....All I get is a string of all ids from 'friend_added' in $frn[$i]....Thanks.</p>
