while循环和implode()函数

I'm looking to fetch some data from a table row. The row, obviously, have a lot of entries. I want to 'array' those entries so I can echo them. The obvious way is to use a loop, of course, but, for design matters, I need to put the while in a window.alert() JS script, but PHP does not execute the loop.

Searching for solutions I found the implode and explode combo, but after some days of thinking I have no clue. Hope there's a way to do what I want. I'll explain it with code.

Firstly I thought I could concatenate the while into a echo, but reading this page comments about it I found that I'm a bit of an idiot.

if(mysqli_num_rows($result)==0)
{
    echo "<script>window.alert('There's no PC for that $email')</script>"; 
}
    else "<script>window.alert('These are $email\'s PCs".
      while($row=mysqli_fetch_array($result) echo $row[0]; ." ')</script>";

EDIT: I show you something very similar that worked (it's not that complex though)

<p>Users' email:</p>

<?php 
  include("connect.php");
  $sql="SELECT * FROM user;";
  if(!($result=mysqli_query($link,$sql)))
    die(mysqli_error($link));
  echo "<select name='users'>";
  while($row=mysqli_fetch_array($result))
    echo "<option value='$row[0]'> $row[0] ";
  echo "</select>";
?>

This prints an option input with all emails. It is embedded in the HTML code. My idea was to do the same with my probleme here, but when pressing a button, it shows what PCs those users' emails have.


Eventually I got some results by creating an alert for each entry, doing the reverse process, inserting the alert into the while (as posted a few lines upper), but is not as 'fancy' as I want it to be.

When I found explode, this was what I thought it might be a good solution, but no..

while($row=mysqli_fetch_row($result))
        {
          $bla=$row[0];
          echo $bla;
        }

        $blabla=implode(",",$bla);
        echo $blabla;

Appending the string you want to output to should be adequate.

while($row=mysqli_fetch_row($result)) {
    $blabla .= $row[0];
}
 Use explode you can have your result.
       while($row=mysqli_fetch_row($result))
        {
          $bla=$row[0];
          echo $bla;
        }

        $blabla=explode(',',$bla);
        print_r($blabla);