Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
433 views
in Technique[技术] by (71.8m points)

I want to save drop down list selected text to database in php . instead of selected text its value 2 getsave

   <select name="Industry"  id="Industry" >
      <option value="">Select Industry</option>
      <option value="2">Account/Finance</option>
      <option value="3">Advertising</option>
     .
     .
   </select>
  <select name="Functional_Area" id="Functional_Area">
    <option value="">Select Functional Area</option>
  </select>

Drop down list Industry and Fucntional_Area get values from database ie.industry_id and            industry_name..ids as you know 1,2,3,4 and respective names .

when I try to save ddl selected text to database It's id value example 2 get saved to database

php code:

  $Industry=mysql_escape_string($_POST['Industry']);
  $insert_query=("INSERT INTO profile_experience_info (industry) values  ($Industry)");
  mysqli_query($conn,$insert_query);

I am a ASP.NET developer where I use to use ddl.Selectedtext property to save selected text to database but i am not getting how to do this in php .. i tried a lot and also donot want to change id's value to match option value which I mostly found on google , eg) I don't want to do this as in my project I have lot of ddl whos db is ready with tons of data..

<select name="Industry"  id="Industry" >
    <option value="">Select Industry</option>
    <option value="Account/Finance">Account/Finance</option>
    <option value="Advertising">Advertising</option>
        .
        .
</select>

plz suggest some another solution to save user selected text to db Please help me in this Thk in advance ..

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

What i understand is that you want to save the text (Account/Finance) instead of 2 which u have given in value... for that u just need to put that text in place of value

<select name="Industry"  id="Industry" >
  <option value="Industry">Select Industry</option>
  <option value="Account/Finance">Account/Finance</option>
  <option value="Advertising">Advertising</option>
 .
 .

hope this will work


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.8k users

...