Loading ...
Sorry, an error occurred while loading the content.

Re: [phpXperts] Dynamic Drop Down list

Expand Messages
  • Tawhidur Rahman
    Yes possible, need to run a while loop for fetching data - where will be formed ... Tawhidur Rahman Assistant Manager Bestway Bazaar
    Message 1 of 8 , Dec 22, 2010
    • 0 Attachment
      Yes possible, need to run a while loop for fetching data - where <option> </option> will be formed
       
      ---
      Tawhidur Rahman
      Assistant Manager
      Bestway Bazaar
      tawhidur.rahman@...
      swapnoloke@...
      http://www.bestwaybazaar.com
      http://www.swapnoloke.com
      Cell : +880(192)9917857



      From: foysal foysal <nowphp@...>
      To: phpexperts@yahoogroups.com
      Sent: Wed, December 22, 2010 1:42:37 PM
      Subject: [phpXperts] Dynamic Drop Down list

       

      Is it possible to populate on drop down list based on another drop down list from mysql data??


    • foysal foysal
      Dear Tawhidur i am talking about two drop down list. it seems you are talking about one drop down list. can you expalin your words with php code??
      Message 2 of 8 , Dec 22, 2010
      • 0 Attachment
        Dear Tawhidur

        i am talking about two drop down list. it seems you are talking about one drop down list. can you expalin your words with php code??

        On Wed, Dec 22, 2010 at 2:15 PM, Tawhidur Rahman <tawhid_r@...> wrote:
         

        Yes possible, need to run a while loop for fetching data - where <option> </option> will be formed
         
        ---
        Tawhidur Rahman
        Assistant Manager
        Bestway Bazaar
        tawhidur.rahman@...
        swapnoloke@...
        http://www.bestwaybazaar.com
        http://www.swapnoloke.com
        Cell : +880(192)9917857



        From: foysal foysal <nowphp@...>
        To: phpexperts@yahoogroups.com
        Sent: Wed, December 22, 2010 1:42:37 PM
        Subject: [phpXperts] Dynamic Drop Down list

         

        Is it possible to populate on drop down list based on another drop down list from mysql data??



      • foysal foysal
        Dear Reza i would like to use only php. have you any soloution?? On Wed, Dec 22, 2010 at 2:00 PM, Reza Shahreare Khan
        Message 3 of 8 , Dec 22, 2010
        • 0 Attachment
          Dear Reza

          i would like to use only php. have you any soloution??

          On Wed, Dec 22, 2010 at 2:00 PM, Reza Shahreare Khan <reza.shahreare@...> wrote:
           

          yes ... it can be done using ajax nicely. but you can do it without ajax.


          first insert first drop down in a form which call itself as action. if the page got value of the post variable set then fetch value from database to populate second dropdown list.

          hope it gives an idea how to do it.


          On Wed, Dec 22, 2010 at 1:42 PM, foysal foysal <nowphp@...> wrote:
           

          Is it possible to populate on drop down list based on another drop down list from mysql data??




          --

          thanking you
          A. H. M. Reza Shahreare Khan
          Web Developer



        • se_lain
          Sure it s possible, but you would have to re-render the entire page. For example lets say you have two drop down boxes to select a car so we have make and
          Message 4 of 8 , Dec 22, 2010
          • 0 Attachment
            Sure it's possible, but you would have to re-render the entire page. For example lets say you have two drop down boxes to select a car so we have make and model. So my psudo code would be something like

            <select Make>
            <?
            $found = Make->get_records()
            while $found
            {
            output option // the value would the key for Make table
            found = Make->next_record()
            }
            ?>
            </select>

            <select Model>
            <?
            if(isset($_POST['Make']))
            found = Model->get_records("id", $_POST['Make'])
            else
            found = Model->get_records() //get all makes
            while found
            {
            output option // the value would the key for Make table
            found = Model->next_record()
            }

            ?>
            </select>


            You could use Javascript to submit the form to itself whenever Make is changed to get all the models for that Make.

            --- In phpexperts@yahoogroups.com, foysal foysal <nowphp@...> wrote:
            >
            > Dear Reza
            >
            > i would like to use only php. have you any soloution??
            >
            > On Wed, Dec 22, 2010 at 2:00 PM, Reza Shahreare Khan <
            > reza.shahreare@...> wrote:
            >
            > >
            > >
            > > yes ... it can be done using ajax nicely. but you can do it without ajax.
            > >
            > > first insert first drop down in a form which call itself as action. if the
            > > page got value of the post variable set then fetch value from database to
            > > populate second dropdown list.
            > >
            > > hope it gives an idea how to do it.
            > >
            > >
            > > On Wed, Dec 22, 2010 at 1:42 PM, foysal foysal <nowphp@...> wrote:
            > >
            > >>
            > >>
            > >> Is it possible to populate on drop down list based on another drop down
            > >> list from mysql data??
            > >>
            > >
            > >
            > >
            > > --
            > >
            > > thanking you
            > > A. H. M. Reza Shahreare Khan
            > > Web Developer
            > >
            > >
            > >
            > >
            >
          • Reza Shahreare Khan
            the solution i gave you was fully in php. first drop down in a form which call itself as action. on change of dropdown list form will be submitted. in the same
            Message 5 of 8 , Dec 22, 2010
            • 0 Attachment
              the solution i gave you was fully in php.

              first drop down in a form which call itself as action. on change of dropdown list form will be submitted. in the same page we have to check if the page have the value of first drop down list. if you got it then use it to fetch data for second dropdown list from database and create the second dropdown list with these value.


              <form method=post action='your_page_url.php'>
              <select name=aaa onchange="submit();">
              <!-- first dropdownlist -->
              </select>
              </form>

              if(isset($_post[aaa]))
              {

              $data=mysql_query("your second dropdownlist data");

              <select name=bbb>

              <!-- second dropdownlist -->
              </select>

              }

              btw: the code above is just to show you how to do it. it is not complete code. there may be syntax error above.

              On Wed, Dec 22, 2010 at 9:30 PM, foysal foysal <nowphp@...> wrote:
               

              Dear Reza

              i would like to use only php. have you any soloution??

              On Wed, Dec 22, 2010 at 2:00 PM, Reza Shahreare Khan <reza.shahreare@...> wrote:
               

              yes ... it can be done using ajax nicely. but you can do it without ajax.


              first insert first drop down in a form which call itself as action. if the page got value of the post variable set then fetch value from database to populate second dropdown list.

              hope it gives an idea how to do it.


              On Wed, Dec 22, 2010 at 1:42 PM, foysal foysal <nowphp@...> wrote:
               

              Is it possible to populate on drop down list based on another drop down list from mysql data??




              --

              thanking you
              A. H. M. Reza Shahreare Khan
              Web Developer






              --

              thanking you
              A. H. M. Reza Shahreare Khan
              Web Developer
              Systematic InfoSys

            • Thouhedul
              yes it is possible. the code can be like that-
              Message 6 of 8 , Dec 22, 2010
              • 0 Attachment
                yes
                it is possible.
                the code can be like that-


                <?php
                //connection to mysql
                //select database

                $qry="select * from table_name";
                $qry=mysql_query($qry);
                while($data=mysql_fetch_array($qry))
                {
                ?>
                <select name="">
                <option value="<?php echo $data['database_value'];?>"><?php echo $data['database_name'];?></option>

                <?php
                }
                ?>
                </select>


                Note:
                1. $data['database_value'] means that, which value will stay in database and what is invisible in webpage.
                2. $data['database_name' means that, that value just show in the webpage.


                Thanks-


                --- In phpexperts@yahoogroups.com, foysal foysal <nowphp@...> wrote:
                >
                > Is it possible to populate on drop down list based on another drop down list
                > from mysql data??
                >
              Your message has been successfully submitted and would be delivered to recipients shortly.