Taking data from database in populate drop down box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #16
    I have no idea what you are talking about. And it does not correspond with any code you showed.

    Anyway, the problem for which you opened this thread is answered and solved.
    Now you are asking for us to write more code for you without showing what you have done yourself to solve it. And we are not here to write your code.

    So explain in a little more detail in plain and concise english, what the problem now is.

    What specializationI D, nowhere to be seen!

    Ronald

    Comment

    • agarwalsrushti
      New Member
      • Feb 2008
      • 63

      #17
      The code which i sent you in that the specialization drop down box is defined for particular set of values. In my project specialization selection differs based on qualification selected. For eg. if the user selects B.E. as qualification then a particular set of specialization drop box should be displayed whereas if the user selects B.Sc as qualification then another set of specialization values should be displayed. Can it be done using php or have i to use javascript for it.
      Thanks.

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #18
        If you want to dynamically populate a new drop down box without having a submit been issued, you must use JavaScript (Ajax) to do that.

        Ronald

        Comment

        • agarwalsrushti
          New Member
          • Feb 2008
          • 63

          #19
          Thanks alot. You were a great help.

          Comment

          • ronverdonk
            Recognized Expert Specialist
            • Jul 2006
            • 4259

            #20
            You are welcome. See you next time in this forum.

            Ronald

            Comment

            • agarwalsrushti
              New Member
              • Feb 2008
              • 63

              #21
              hi,
              I had a problem with htose drop downs. Im not able 2 retrieve the selected values. For eg. if the user has selected a particular area name then i want its coresponding id to b stored in the database. Bt im not able 2 store it neither in database nor in a variable.

              Comment

              • ronverdonk
                Recognized Expert Specialist
                • Jul 2006
                • 4259

                #22
                There is no area ID in your option list, just the description and that is what is passed to you.

                If you want to associate an options description with an ID and have that passed, you must add the value attribute to the option statement, such as [php]<option value='1'>area of interest</option>[/php]Ronald

                Comment

                • agarwalsrushti
                  New Member
                  • Feb 2008
                  • 63

                  #23
                  In the functional area drop down i passed the id also using the following code shown below.

                  [code=php]
                  <?php

                  // Make connection to server and database
                  $dbi=mysql_conn ect($hostname, $db_user, $db_password)
                  or die('Error connecting to mysql');
                  mysql_select_db ($db_name,$dbi) ;

                  // select the data from db
                  $query = mysql_query("SE LECT AreaName,Functi onalAreaId FROM functionalarea" )
                  or die("SELECT Error: ".mysql_error() );

                  // start the select list
                  echo '<select name="AreaName" value="Function alAreaId">';
                  echo '<OPTION value="" selected>-Select-</OPTION>';

                  // read each row field and build option list
                  while($row = mysql_fetch_arr ay($query)) {
                  echo("<option value=$row[FunctionalAreaI d]>$row[AreaName]</option>");
                  }

                  // close the select list
                  echo "</select>";
                  ?>
                  [/code]

                  Bt im not able to retrieve FunctionalAreaI d value of selected AreaName in my insert statement.

                  Comment

                  • ronverdonk
                    Recognized Expert Specialist
                    • Jul 2006
                    • 4259

                    #24
                    There is no FunctionalAreaI d variable in sight in the code that you showed us.

                    Ronald

                    Comment

                    • agarwalsrushti
                      New Member
                      • Feb 2008
                      • 63

                      #25
                      Its there in select statement on line 9 and on line 13
                      In the file i attached below i want to insert it in the database using the query on line 253. but its not geting inserted.
                      Attached Files

                      Comment

                      • agarwalsrushti
                        New Member
                        • Feb 2008
                        • 63

                        #26
                        My previous problem has yet not solved. Ive tried a code for which you told to use javascript. I first tested it on a small database all work fined but its not working with my project database. Again its not displaying any values on the form. The code that i ve used is pasted below. Plz check it n let me know if theres an error somewhere around.

                        [code=php]
                        <?php

                        // Make connection to server and database
                        $dbi=mysql_conn ect($hostname, $db_user, $db_password)
                        or die('Error connecting to mysql');
                        mysql_select_db ($db_name,$dbi) ;

                        // select the data from db
                        $query = mysql_query("SE LECT * FROM qualification")
                        or die("SELECT Error: ".mysql_error() );

                        // start the select list
                        echo '<select name="Qualifica tionName">';
                        echo '<OPTION value="" selected>-Select-</OPTION>';

                        // read each row field and build option list
                        while($row = mysql_fetch_arr ay($query)) {
                        echo "addOption(docu ment.drop_list. Qualification, '$row[QualificationId]', '$row[QualificationNa me]');";
                        //echo("<option>$ row[QualificationNa me]</option>");
                        }
                        // close the select list
                        echo "</select>";
                        ?>

                        function addOption(selec tbox, value, text )
                        {
                        var optn = document.create Element("OPTION ");
                        optn.text = text;
                        optn.value = value;

                        selectbox.optio ns.add(optn);
                        }

                        [/code]

                        Comment

                        • agarwalsrushti
                          New Member
                          • Feb 2008
                          • 63

                          #27
                          Hi,
                          All my problem is solved. Now only i am not able to insert the value of selected name in drop down into database. Plz help me out with this. Just tell me what i should do to store that data.
                          Thanks a lot.

                          Comment

                          Working...