Remembering users choices in drop down lists (form)
Posted: Wed Dec 16, 2009 9:22 am
Hello all,
I've been building a CMS system and have virtually completed it - when the client wants to edit something from the database, say a case study, they select edit and are met with a standard html form to fill in and update the details. I'm pulling in the existing details for the case study into the form choices as follows:
...so using the $data variable to fill out the form - my problem comes when I have a drop down list of 6 options, where they choose the section they wish to put the case study in. There's a choice of 6 in the drop down list as follows:
What I really need is a way of the drop down list remembering which section the case study is associated with, to go with the existing content being displayed in the various form fields on the rest of the form - does anyone know how to do this, as I can't see an obvious solution - I need the values to be 1,2,3,4,5,6 and the words in between to be certain sections.
Cheers
I've been building a CMS system and have virtually completed it - when the client wants to edit something from the database, say a case study, they select edit and are met with a standard html form to fill in and update the details. I'm pulling in the existing details for the case study into the form choices as follows:
Code: Select all
<?php
//connect to database
mysql_pconnect ($host, $user, $pass) or die ("Login info is incorrect") ;
mysql_select_db ($database);
//selects everything from the table and puts it in to $result variable
$result = mysql_query("SELECT * FROM $tableTen WHERE id=" . $_GET['id']);
$data = mysql_fetch_array($result);
<form input section......
<input type="text" tabindex="1" name="casestudy_name" value="<?php echo $data['name'] ?>" style="width:245px" />
<textarea name="casestudy_information" tabindex="3" rows="12" cols="50" style="width:450px"><?php echo $data['information'] ?></textarea>
etc etc
?>
Code: Select all
<select name="client_id">
<option value="0">Choose section...</option>
<option value="1">section 1</option>
<option value="2">section 2</option>
<option value="3">section 3</option>
<option value="4">section 4</option>
<option value="5">section 5</option>
<option value="6">section 6</option>
</select>
Cheers