Jump to content

need help in dynamic select menu in php


doforumda

Recommended Posts

hi i have created a dynamic select menu using php. i have a problem in that which is when the user select any value in that menu and press submit then it does not pass to next page.

 

my code is here

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>

<body>
<?php
$db = mysql_connect("localhost");
mysql_select_db("test", $db);
$query = "SELECT * FROM day" or die(mysql_error()); // id='".$id."'
//echo $query;
$result = mysql_query($query) or die(mysql_error());


?>
<form name="form1" method="post" action="date.php">
  <label>Date:
  <select name="day" id="day">
  <?php while( $row = mysql_fetch_array($result) ) { ?>
    <option value="<?php $row['id']; ?>"><?php echo $row['day']; ?></option>
    <?php } ?>
  </select>
  </label>
  <p>
    <label>
    <input type="submit" name="button" id="button" value="Submit">
    </label>
  </p>
</form>
</body>
</html>

 

the next page is

<?php
$day = $_POST["day"];

echo $day;
?>

Link to comment
https://forums.phpfreaks.com/topic/177750-need-help-in-dynamic-select-menu-in-php/
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.