[SOLVED]Populating a dynamic list box
Posted: Mon Mar 06, 2006 1:34 pm
Hi,
Can anyone help me with this?
I am trying to populate a list box with values from a database but the only output that ends up in the list box is the last element of the array.
I can see what is happening - the assignment of $tag_list just gets overwritten with each iteration of the loop instead of being appended to the end of it.
Is there a better way of doing this (I'm sure there is)?
Thanks in advance.
rj
Can anyone help me with this?
I am trying to populate a list box with values from a database but the only output that ends up in the list box is the last element of the array.
I can see what is happening - the assignment of $tag_list just gets overwritten with each iteration of the loop instead of being appended to the end of it.
Is there a better way of doing this (I'm sure there is)?
Code: Select all
$tags = array($fetch_tag['tag']);
$tag_list = '<select name="tag_list" size="10">';
for($x=0; $x<=$tag_count; $x++){
$tag_list .= ' <option value="">' . $tags[$x] . '</option>';
}
$tag_list .= '</select>';rj