SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    parameters not being updated

    hi,
    im having a problem with parameters. i have two files - autoplan.php and editplan.php. autoplan randomly generates 14 different recipes (7 vegetarian 7 not) from the database. The user can edit this and clicks a link which does so. this passes th 14 names to the edit page. the edit page has 14 drop down boxes each drop down box has a default value of whatever parameter has been passed to it(eg the first vegetarian dish suggested will be the selected value of the first drop down box). the first 7 drop down boxes are populated with vegetarian recipes and the second 7 with non vegetarian recipes,
    all this works fine, its the next part im having a problem with.....

    what i want to happen is the user selects whatever they want to change in any of the drop down boxes and click submit. this opens up autoplan.php and passes back 14 parameters

    what the problem is:
    if for example the 1st suggested recipe was spaghetti bolognese and this was passed to the edit page and the user changed it to fish and chips via the edit page and clicked the submit button. autoplan would open and the parameter passed back would be spaghetti bolognese still, bot fisg and chips.

    here is my code:

    autoplan.php parameter pass:

    PHP Code:
                //hyperlink opens edit page and passes required parameters
                
    echo'<a href = "edit_pages/editplan.php?
                vdish1=' 
    $vsuggestions[0] . '&amp;
                vdish2=' 
    $vsuggestions[1] . '&amp;
                vdish3=' 
    $vsuggestions[2] . '&amp;
                vdish4=' 
    $vsuggestions[3] . '&amp;
                vdish5=' 
    $vsuggestions[4] . '&amp;
                vdish6=' 
    $vsuggestions[5] . '&amp;
                vdish7=' 
    $vsuggestions[6] . '&amp;
                dish1=' 
    $suggestions[0] . '&amp;
                dish2=' 
    $suggestions[1] . '&amp;
                dish3=' 
    $suggestions[2] . '&amp;
                dish4=' 
    $suggestions[3] . '&amp;
                dish5=' 
    $suggestions[4] . '&amp;
                dish6=' 
    $suggestions[5] . '&amp;
                dish7=' 
    $suggestions[6] . '
                ">Edit</a><br />'

    editplan.php

    PHP Code:
        <form action = "<?php echo "../autoplan.php?dish1=$dish1"?>" method = "post" name = "editmenu">

        <p><h1>Edit Suggested Weekly Menu</h1></p>


        <?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] = $vdish1;
            
    $vsuggesteddishes[2] = $vdish2;
            
    $vsuggesteddishes[3] = $vdish3;
            
    $vsuggesteddishes[4] = $vdish4;
            
    $vsuggesteddishes[5] = $vdish5;
            
    $vsuggesteddishes[6] = $vdish6;
            
    $vsuggesteddishes[7] = $vdish7;
                


            
    $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 = 'Yes'")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++;
            }

                

        
    ?>


        <p><h2>Non Vegetarian Dishes</h2></p>

        <?php

            $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 = 'No'")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++;


            }


            
    $dish1 $_POST['newdish1'];

        
    ?>




    <p><input type = "submit" value = "SUBMIT"/></p>
            

    </form>
    there is only 1 variable passed from editplan.php to autoplan.php there will, when the problem is sorted, be 14 passed back!

    hope i explained this ok and someone can help!

    thaniks

  2. #2
    SitePoint Member hermawan's Avatar
    Join Date
    Jul 2003
    Location
    Jakarta, Indonesia
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not quite sure I understand the problem . You seems to use the variables posted/queried from another page with register_globals Off.
    Hermawan Haryanto
    Red Rock Reef - Asia | hermawan@redrockreef.asia

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    im basically passing variables to a page, changing them on that page and passing them back again. does that explain it better?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •