Hi there everyone,
I don't understand arrays that well and am trying to modify one that someone else helped me with here previously.
I've created a table called classifieds_currencies which has four rows, id(incremental), symbol, abbreviation, description.
I'm trying to create a selection box dropdown for a form that will allow the user to choose their currency. I would like the option string to get populated like this:
<option value='1'>$ USD (United States Dollar)</option>
Which would be in the format of:
<option value='$id'>$symbol $abbreviation ($description)</option>
This is what I ended up with when modifying the array someone else had helped me with previously:
/*Generating currency dropdown.*/
$query = "SELECT * FROM `classifieds_currencies` ORDER BY `id` ASC;";
$result = mysql_query($query);
$currencies = array();
while ($row = mysql_fetch_assoc($result)) {
$currencies[$row['id']] = $row['symbol']." ".$row['abbreviation']." (".$row['description'].")";
}
<--------------------cut--------------------------->
<select name='adcreate_currency' id='adcreate_currency'>");
foreach ($currencies as $id => $abbreviation) {
echo("<option value='".$id."'");
/*Select the proper option if it's retrieved from the db.*/
if($id == $adcreate_currency){
echo(" selected");
}
echo(">".$title."</option>"."\n" );
}
echo("</select><br />
My array is populating only the id, so my option string looks like this:
<option value='1'></option>
Could anyone help me figure out where I went wrong so I have a working selection box?
thanks,
json