So this is what I’m trying to do..
$sql="SELECT * FROM `members";
while($rew = mysql_fetch_array($sql)){
$var[] =",'".$rew['username']."'";
}
print_r ($var)
So I get the result:
Array ( [0] => ",'John'", [1] => ",'Mason'", [2] => ",'Greg'", [3] => ",'Paul'" )
So now I want the variable to display all results when I echo. For example:
<?php echo $var[1] ?>
And the result will be just ,'Mason'.
How do I get it so that I can echo $var[*] and get all the results. “John,Mason,Greg,Paul”.
I have been trying to figure this out for a very long time and is getting very frustrating for me. Can someone please help me.
Use PHP’s
implodefunction.And change your loop code to: