Repopulate dropdown box from users previous selection
Posted: Wed Jul 14, 2010 8:30 am
Hello - I hope you can help
I've searched but no joy but i think that's partly because I'm not sure what I should be searching for.
I have a dropdown box where the box options come from a table
The user selects multiple items and these are passed into a database like
Which gives a database record such as
a:3:{i:0;s:0:"";i:1;s:0:"";i:2;s:0:"";}
Question: When the user wishes to change their previous selection, how do I repopulate the dropdown box with their previously chosen items?
Also, as a side note, I'm struggling to "interpret" how the array -- a:3:{i:0;s:0:"";i:1;s:0:"";i:2;s:0:"";} -- matches anything from the original section other than 3 items were selected which make me think that bit is wrong.
Many thanks in advance.
Chris
I've searched but no joy but i think that's partly because I'm not sure what I should be searching for.
I have a dropdown box where the box options come from a table
Code: Select all
<label for="genre">Genre</label><br />
<select name='genre[]' size=4 multiple>
<?
$query="SELECT genre FROM genre ORDER BY genre ASC";
$result = mysql_query ($query);
while($nt=mysql_fetch_array($result)){
$genre_id=$nt['genre_id'];
$genre_name=$nt['genre'];
echo "<option value=$genre_id>$genre_name</option><br />";
}
?>
</select>
Code: Select all
$artist_genre=serialize($_POST['genre']);
a:3:{i:0;s:0:"";i:1;s:0:"";i:2;s:0:"";}
Question: When the user wishes to change their previous selection, how do I repopulate the dropdown box with their previously chosen items?
Also, as a side note, I'm struggling to "interpret" how the array -- a:3:{i:0;s:0:"";i:1;s:0:"";i:2;s:0:"";} -- matches anything from the original section other than 3 items were selected which make me think that bit is wrong.
Many thanks in advance.
Chris