Jump to content

Post Value from Dynamic Select List


BeanoEFC

Recommended Posts

Hey Every1,

 

I am trying to send a value submitted from a dynamic select list to a different page.  However im running into problems.  Here is my code for the 2 pages

 

<html>
<head>
</head>
<body>
<form name="blah" method="post" action="selectlist3_1.php">     
<select>
    <option>--Select Ride Destination--</option>
    <?php
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

    $query="select ride_name from ridedetails order by ride_name asc";
    $result=mysql_query($query);
    while(list($ride_name)=mysql_fetch_row($result)) {
        echo "<option name='ride_name' value=" . $ride_name . ">" . $ride_name . "</option>";
    }
    ?>
</select>
<input type="submit" name="Submit" value="Submit"  />
</form>
</body>
</html>

 

<html>
<head>
</head>
<body>
<?php 

$ride_name_post = $_POST['ride_name'];
$ride_name_get = $_GET['ride_name'];

echo "hello";
echo "<br>";
echo "Ride Name (get) : " . $ride_name_get;
echo "<br>";
echo "Ride Name (post) : " . $ride_name_post;

?>
</body>
</html>

 

I have been trying to duplicate the way i send values via a textfield by giving the <option> tag a name and and capturing the value by using $_POST['ride_name']. This is not working though.

 

Any help would be appreciated.

Regards,

-Beano

Link to comment
https://forums.phpfreaks.com/topic/186004-post-value-from-dynamic-select-list/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.