Connecting Tech Pros Worldwide Forums | Help | Site Map

Unable to retrieve id from dropdown

Member
 
Join Date: Feb 2008
Posts: 63
#1: Mar 12 '08
Hi,
Ive made dynamic drop down boxes. On selection of value from first drop down box the values in second drop down are displayed. I ve made this two drop down in a separate file. I want to store the id value of the selected name in the drop down into database. I am able to store the value of first drop down but the value of second drop down is always saved as 0 in the database.
I think its just a small error im am making somewhere. I think the change has to be made on line 232 in insert statement of process.php file
I ve given the code of both my files below plz let me know how it can be fixed.
Attached Files
File Type: txt process.txt (17.0 KB, 26 views)
File Type: txt list.txt (1.7 KB, 14 views)

Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,938
#2: Mar 12 '08

re: Unable to retrieve id from dropdown


You only need to include the relevant code.
You've supplied too much.
Member
 
Join Date: Feb 2008
Posts: 63
#3: Mar 12 '08

re: Unable to retrieve id from dropdown


Heres the relevant code i think where the change needs to be done.
This is the code for drop down box.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. require "config.php"; // database connection details 
  4. echo "
  5.  
  6. function fillQualification(){ 
  7.  // this function is used to fill the Qualification list on load
  8.  
  9. ";
  10.  
  11. $q1=mysql_query("select * from qualification");
  12. echo mysql_error();
  13. while($nt1=mysql_fetch_array($q1)){
  14. echo "addOption(document.form1.Qualification, '$nt1[QualificationId]', '$nt1[QualificationName]');";
  15. }// end of while
  16. ?>
  17. } // end of JS function
  18.  
  19. function SelectSpecial(){
  20. // ON or after selection of qualification this function will work
  21.  
  22. removeAllOptions(document.form1.Specialization);
  23. addOption(document.form1.Specialization, "", "-Select-", "");
  24.  
  25. // Collect all element of Specialization for various QualificationId 
  26.  
  27. <?php 
  28. // let us collect all QualificationId and then collect all Specialization for each QualificationId
  29. $q2=mysql_query("select distinct(QualificationId)  from specialization");
  30. // In the above query you can collect QualificationId from qualification table also. 
  31. while($nt2=mysql_fetch_array($q2)){
  32. echo "if(document.form1.Qualification.value == '$nt2[QualificationId]'){";
  33. $q3=mysql_query("select SpecializationArea from specialization where QualificationId='$nt2[QualificationId]'");
  34. while($nt3=mysql_fetch_array($q3)){
  35. echo "addOption(document.form1.Specialization,'$nt3[SpecializationId]', '$nt3[SpecializationArea]');";
  36.  
  37.  
  38. } // end of while loop
  39. echo "}"; // end of JS if condition
  40.  
  41. }
  42. ?>
  43. }
  44.  
This is the insert statement from where the details go in database.
Expand|Select|Wrap|Line Numbers
  1. mysql_query("INSERT INTO $db_table1(UserName,PhoneNo,MobileNo,YearsExp,MonthsExp,FunctionalArea,KeySkills,Qualification,Specialization,Institute,FunctionalRoles,CurrentEmployer,PreviousEmployers,ProfileTitle,ResumeFile) values ('$_POST[UserName]','$_POST[PhoneNo]','$_POST[MobileNo]','$_POST[YearsExp]','$_POST[MonthsExp]','$_POST[AreaName]','$_POST[KeySkills]','$_POST[Qualification]','$_POST[Specialization]','$_POST[InstituteName]','$_POST[RoleName]','$_POST[CurrentEmployer]','$_POST[PreviousEmployers]','$_POST[ProfileTitle]','$_POST[ResumeFile]')") 
  2. or die(mysql_error());
  3.  
Reply


Similar PHP bytes