473,395 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

how do i insert 3 values into same database field

29
i have 3 drop down which the user can only select one each has they own name like select 1 select 2 and select 3 but i want whichever the user select to go into the same field on the database.. at the moment i named the field select3 but that only store value of the drop down named SELECt3 how do i get if user chose select2 insert the value on same field as if chose select 1 or 3

i tried
Expand|Select|Wrap|Line Numbers
  1. $select3 = $_POST['select1 || select2 || select3'];
  2.  
  3.  
  4. $query="INSERT INTO photos values ('$select3')"; 
  5.  
  6.  
  7. this is the drop down
  8.  
  9. [PHP]$select3 = $_POST['select1 && select2 && select3'];
  10.  
  11.  
  12.  
  13.  
  14.  
  15. $query="INSERT INTO photos values ('$select3')";
  16.  
  17.  
  18.  
  19.  
  20.  
  21. <select id="in-campu" name="select1">
  22.  
  23.  <option name="hot"  value="default">--Select  Music Type--</option>
  24.  
  25. <option name="how" value="Concerts">Concerts</option>
  26.  
  27. <option name="hot" value="Clubs" >Clubs</option>
  28.  
  29. <option name="hot" value="Festival">Festival</option>
  30.  
  31. <option name="hot" value="Opera">Opera</option>
  32.  
  33.  
  34.  
  35. </select>
  36.  
  37.  
  38.  
  39.     <select id="off-campus" class="item" name="select2" style="display: none;">
  40.  
  41.  <option name="hot" value="default"> -- Select Sport Type -- </option>
  42.  
  43. <option name="hot" value="Formula 1">Formula 1</option>
  44.  
  45. <option name="hot" value="Footbal">Footbal</option>
  46.  
  47. <option name="hot" value="Basketball">Basketball</option>
  48.  
  49. <option name="hot" value="Rugby">Rugby</option>
  50.  
  51. <option name="hot" value="Cricket">Cricket</option>
  52.  
  53. </select>
  54.  
  55.  
  56.  
  57.     <select id="one" class="item" name="select3" style="display: none;">
  58.  
  59. <option name="one" value="default"> -- Select Art & Theatre Type -- </option>
  60.  
  61. <option name="one" value="Comedy">Comedy</option>
  62.  
  63. <option name="one"  value=" Drama">Drama</option>
  64.  
  65. <option name="one" value="Museus">Museus</option>
  66.  
  67. </select>
Apr 20 '10 #1
1 1947
Atli
5,058 Expert 4TB
Hey.

So, basically, you allow the user to select from only one of the <select> boxes, and you need the value of that box to be inserted into the database?

If so, you would simply have to go through the boxes, one by one, and check if they have a value. Like:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $value = null;
  3. if(isset($_POST['select1']) && !empty($_POST['select1'])) {
  4.     $value = $_POST['select1'];
  5. }
  6. else if(isset($_POST['select2']) && !empty($_POST['select2'])) {
  7.     $value = $_POST['select2'];
  8. }
  9. else ( // {
  10.     // A box was not submited.
  11.     echo "Please select something!";
  12. }
  13.  
  14. if($value == null) { // !
  15.     // Insert the value into a database
  16. }
  17. ?>
Apr 20 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: jason | last post by:
How does one loop through the contents of a form complicated by dynamic construction of checkboxes which are assigned a 'model' and 'listingID' to the NAME field on the fly in this syntax:...
10
by: shank | last post by:
I have a recordset that contains multiple records of product a user is purchasing. For clarity, I converted the recordset fields to variables. I need to take that entire recordset and insert it...
1
by: Christian Soltenborn | last post by:
Hi experts, I am working on a university project based on VB .NET. I have a connection to MS Access, and I want to insert some data into the database. The sql command INSERT INTO Shoe (Brand,...
10
by: Mike | last post by:
I know this sounds strange but I am at a loss. I am calling a simple funtion that opens a connection to a SQL Server 2000 database and executes an Insert Statement. private void...
3
by: Hai Nguyen | last post by:
Hi all I was attempting to insert multiple row by using a loop into a database.A table has 2 primary keys and one regular field (PR) (PR) ID Project Ans 1 2 a 1 ...
1
by: Miguel Dias Moura | last post by:
Hello, i am inserting some form values in a database. Two of this values are as follows: <Parameter Name="@FirstName" Value='<%# IIf(FirstName.SelectedItem.Value <> "",...
1
by: ven | last post by:
hello i`m makin a asp.net service with database connection where i have an insert with decimal value, when i run my function i get this error : There are fewer columns in the INSERT statement...
0
by: Eustice Scrubb | last post by:
In line coding problem. Here's my code: <script language="VB" runat="server"> Dim myConnection As SqlConnection Sub Page_Load(Src As Object, e As EventArgs) ' Create a connection to the SQL...
7
by: David Bear | last post by:
I have a dictionary that contains a row of data intended for a data base. The dictionary keys are the field names. The values are the values to be inserted. I am looking for a good pythonic...
0
chumlyumly
by: chumlyumly | last post by:
Hello scripters - OS: Mac OSX Language: PHP w/ MySQL database I've created an insert page where a user inputs his info, which then goes to four different tables in a MySQL database. The...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.