Re: Dropdown menu
| From: | Daniel Clark | Date: | Tue, 11 May 2004 10:54:25 +0000 |
| Subject: | Re: Dropdown menu | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-185890@lists.php.net to get a copy of this message | ||
Hi Bill.
Put something like:
<FORM ACTION="read_form.php" METHOD="post">
##your form selections here##
</FORM>
Then on your read_form.php page:
$what_they_selected = $_POST['name1']
>>A question about forms and PHP. I have a dropdown list which gets the lines
>>in the list from DB. Like this(col1 is used only for sorting the data):
>>
>>echo "<td>choose one:</td><td><SELECT
>>NAME=\"name1\">";
>>$sql="SELECT col1, col2 FROM table_04 ORDER BY col1";
>>$result=mysql_query($sql);
>>$num = mysql_num_rows($result);
>>$counter = 1;
>>while ($num >= $counter) {
>>$row = mysql_fetch_array($result);
>>$col2 = $row["col2"];
>>echo "<option value=\"name\">$col2</option>";
>>$counter++;
>>}
>>
>>This obviously leaves the value of $col2 to what ever is in the last row in
>>database. How do I set the script to change the value when user selects
>>another name from the list? I need to do more stuff based on the users
>>selection. How do I get the selection from the list to a variable? I haven't
>>really done forms and PHP before ;-)
>>
>>Thanks
>>Bill