trouble passing correct POST variables
Posted: Fri Apr 27, 2007 1:32 pm
i have the following code
which takes in values from the page this is accessed from, creates 14 drop down boxes in total with the passed parameter as the default for each box. on the click of the button the page loads the correct page and passes the parameter which is the value of the field newdish1 (obviously there this will happen for each field but im tring to get it working for 1) however if the user changes the value, the same value is passed back that was passed in. why is the value not being updated? i hope this makes sense!
Code: Select all
<form action = "<?php echo "../autoplan.php?dish1='$dish1'"; ?>" method = "post" name = "editmenu">
<?php
//connect to server and database
include_once '../includes/connect.inc.php';
echo "<h2>Edit Vegetarian Dish Suggestions</h2>";
//add parameters passed from autoplan.php into an array. each array element holds a meal
//that autoplan.php suggested
$suggesteddishes = array();
$suggesteddishes[1] = $dish1;
$suggesteddishes[2] = $dish2;
$suggesteddishes[3] = $dish3;
$suggesteddishes[4] = $dish4;
$suggesteddishes[5] = $dish5;
$suggesteddishes[6] = $dish6;
$suggesteddishes[7] = $dish7;
$vsuggesteddishes[1] = $dish8;
$vsuggesteddishes[2] = $dish9;
$vsuggesteddishes[3] = $dish10;
$vsuggesteddishes[4] = $dish11;
$vsuggesteddishes[5] = $dish12;
$vsuggesteddishes[6] = $dish13;
$vsuggesteddishes[7] = $dish14;
$iterationno = 1;
//create 7 drop down boxes
while($iterationno < 8)
{
//select the names of all vegetarian dishes from the database
$getalldishes = @mysql_query("SELECT name FROM dishes WHERE vegetarian = 'Yes'")or die(mysql_error());
echo "<p><select name = \"newdish$iterationno\" size = 1>";
//default option in list in iteration number in suggested dishes array which is the name in the dish name
//variable passed from autoplan.php
echo"<option selected value =\"{$suggesteddishes[$iterationno]}\">{$suggesteddishes[$iterationno]}</option>";
//loop to retrieve all records that satisfy query
while ($row = mysql_fetch_array($getalldishes))
{
//gets each value from database and makes it an option in the list
echo"<option value =\"{$row['name']}\">{$row['name']}</option>";
}
echo"</select></p>";
$iterationno++;
}
$IT = 1;
//create 7 drop down boxes
while($IT < 8)
{
//select the names of all vegetarian dishes from the database
$getallnonvegdishes = @mysql_query("SELECT name FROM dishes WHERE vegetarian = 'No'")or die(mysql_error());
echo "<p><select name = \"newnonvegdish$IT\" size = 1>";
//default option in list in iteration number in suggested dishes array which is the name in the dish name
//variable passed from autoplan.php
echo"<option selected value =\"{$vsuggesteddishes[$IT]}\">{$vsuggesteddishes[$IT]}</option>";
//loop to retrieve all records that satisfy query
while ($row = mysql_fetch_array($getallnonvegdishes))
{
//gets each value from database and makes it an option in the list
echo"<option value =\"{$row['name']}\">{$row['name']}</option>";
}
echo"</select></p>";
$IT++;
$dish1 = $_POST['newdish1'];
?>