I can loop through a table, grab the rows and echo them out within the loop. How do I use this data outside the loop?
$query=("SELECT * FROM poplinks");
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
$popid = $row['popid'];
$popname = $row['popname'];
$popurl = $row['popurl'];
echo $popurl;
}
The echo statement above echos the 10 popurl values in the db, but if I try and echo $popurl outside of the loop I only get the last value. I guess I want an array of all the values stored in a variable.
Update: The data is going into something like the below HTML: (note "echo $popurl" on line 3. The idea is to get the Twitter Bootstrap Typeahead function to read from a database. At the moment by appending [] to each of the variables inside the loop, I can get the below code working if I include the index e.g. but I can't get the entire row in there.
<div class="well">
<form action="" method="post" onsubmit="proceed();">
<input type="text" class="span3" name="content" value="<?php echo $liLink->sContent; ?>" data-provide="typeahead" data-items="4" data-source='["Alabama", "<?php echo $popurl ?>" ,"Alaska","Arizona","Arkansas"]'/>
<input type="submit" name="submit" value="save" />
</form>