I need a little help with my PHP. Basically I have a field a page that I need the code to produce an outcome that looks like:
$existing_users=array('bra','vis','rfm');
Where it pulls the 'bra', 'vis', 'rfm' from the database.
So I figured cool lets make this into an array, and then explode it / separate it with '', Which I am not sure is the best approach, though I guess that's where my logic took me. And so I created the array
mysql_select_db($database_db, $db);
$result = mysql_query('SELECT * FROM clients') or exit(mysql_error());
while ($row = mysql_fetch_assoc($result)) {$array[] = $row['shortcode'];}
print_r($array);
Which gives me this:
Array
(
[0] => bra
[1] => vis
[2] => rfm
)
This is where I am stuck. I am not quite sure how to make things happen to my desired result. If anyone can provide me with advice I would be really appreciative.
echo $array[1];which will outputvis, also stop using mysql_* functions and move to PDO or mysqliprint_r($existing_users);? It will print out exactly what you create fromMySQL