dropdown list populated from stores table in database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DavidOwens
    New Member
    • Mar 2007
    • 56

    dropdown list populated from stores table in database

    Hey everybody

    im creating a report for regional managers, i have created a table called STORES, what i want to be able to do is that when the page loads,

    it currents has the users name n id, but in the days columns mon-sat its empty, and i would like to hace those colums contain drop down lists of the stores from the stores table and save by default when the page next loads, so they dont have to keep going through the dropdown lists.

    iv beden rackin my brain, even just manually filled dropdown lists,but thought if could get it from database it would be better.

    thanks guys.....everyb ody is always very helpful
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Do you mean you want to load the drop downs from the db, have the user select an entry/entries, submit the form and then save that dropdown value or values for the next page?

    If not, explain and show some of the code you have made, maybe it gets more clear.

    And do not forget to enclose that shown code within php or code tags! Otherwise it will be unreadable for us.

    Ronald :cool:

    Comment

    • DavidOwens
      New Member
      • Mar 2007
      • 56

      #3
      Originally posted by ronverdonk
      Do you mean you want to load the drop downs from the db, have the user select an entry/entries, submit the form and then save that dropdown value or values for the next page?

      If not, explain and show some of the code you have made, maybe it gets more clear.

      And do not forget to enclose that shown code within php or code tags! Otherwise it will be unreadable for us.

      Ronald :cool:
      they have a main screen, click the region so say region1, they then put in password, this then redirects them to a table containg user information for that area.

      mon-sat users will be in locations, which i would like to be displayed as a drop down,but they are automaticaly generated from the database, they then check the checkbox to save as default, so they page is displayed with the locations stored when viewed again.

      Comment

      • code green
        Recognized Expert Top Contributor
        • Mar 2007
        • 1726

        #4
        It sounds like php cookies may be the answer to this problem

        Comment

        • DavidOwens
          New Member
          • Mar 2007
          • 56

          #5
          Originally posted by code green
          It sounds like php cookies may be the answer to this problem
          php cookies?

          Comment

          • code green
            Recognized Expert Top Contributor
            • Mar 2007
            • 1726

            #6
            OK maybe not!
            Why not save the users selection into a seperate field?
            Then when the same user logs on, check if he has anything in that field.

            Comment

            • xerc
              New Member
              • Mar 2007
              • 14

              #7
              Maybe I don't understand your need, but is all you want is a drop down menu dynamically created from a PHP query to a database? And then the user selection of the drop down menu carried to the next page?

              If so, you would do something like this. The value of pull down menu #1 on the first page might be referenced as 'select1a'. This gets passed in a URL post to the next page through the typical form submit. So something like "page2.php?$use rselection1=$se lect1a" would be the URL in your form post value. Page two then uses the exact same dynamic method to create the pull down menu, but now you insert the $userselection1 value (which was the menu name/value of $select1a from page1.php) passed in the URL as a 'selected' option in the menu before looping to populate the list. For instance <option value=\"$userse lection1\" selected>$users election1</option. If $userselection1 is a value but not the lable you want displayed in the drop down menu, you'd have to do a separate database query to retrieve the associated name value on page 2. In quasi script, it would be like.

              ----------------------------------------------
              PAGE1.php
              ----------------------------------------------

              SELECT * FROM youtable ORDER BY whatever

              print "<select name=\"select1a \">";

              for ($x=0; $x <= mysql_num_rows; $x++){

              print "<option value=\"$row[value]"\>$row[name]</a>";

              }

              print "</select>";

              -----------------------------------------------
              ***Now post the value from the menu option to page2.php in the URL through a form submit, such that page2.php URL is, page2.php?users election1=$sele ct1a. Obviously you could use sessions or more advanced methods to pass the values, but this is the cheap and dirty.***
              ----------------------------------------------

              ----------------------------------------------
              page2.php
              ----------------------------------------------

              SELECT * FROM youtable ORDER BY whatever

              print "<select name=\"select1a \">";

              print "<option value=\"$userse lection1\" selected>$users election1</option>"

              for ($x=0; $x <= mysql_num_rows; $x++){

              print "<option value=\"$row[value]"\>$row[name]</a>";

              }

              print "</select>";

              Comment

              Working...