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 $select3 = $_POST['select1 || select2 || select3']; $query="INSERT INTO photos values ('$select3')"; PHP: $select3 = $_POST['select1 && select2 && select3']; $query="INSERT INTO photos values ('$select3')"; <select id="in-campu" name="select1"> <option name="hot" value="default">--Select Music Type--</option> <option name="how" value="Concerts">Concerts</option> <option name="hot" value="Clubs" >Clubs</option> <option name="hot" value="Festival">Festival</option> <option name="hot" value="Opera">Opera</option> </select> <select id="off-campus" class="item" name="select2" style="display: none;"> <option name="hot" value="default"> -- Select Sport Type -- </option> <option name="hot" value="Formula 1">Formula 1</option> <option name="hot" value="Footbal">Footbal</option> <option name="hot" value="Basketball">Basketball</option> <option name="hot" value="Rugby">Rugby</option> <option name="hot" value="Cricket">Cricket</option> </select> <select id="one" class="item" name="select3" style="display: none;"> <option name="one" value="default"> -- Select Art & Theatre Type -- </option> <option name="one" value="Comedy">Comedy</option> <option name="one" value=" Drama">Drama</option> <option name="one" value="Museus">Museus</option> </select> PHP:
It is totally against database normalization. Please consider redesigning your table with every row for a value.
You could serialize your 'select' data before storing it, which will give your a storable representation of the data. E.G if your post data is; Array ( [select1] => default [select2] => default [select3] => Comedy ) Code (markup): <?php # NOTE: YOU SHOULD VALIDATE THIS DATA BUT JUST AS AN EXAMPLE $details['select1']=$_POST['select1']; $details['select2']=$_POST['select2']; $details['select3']=$_POST['select3']; $result = serialize($details); print $result; ?> PHP: OUTPUT:a:3:{s:7:"select1";s:7:"default";s:7:"select2";s:7:"default";s:7:"select3";s:6:"Comedy";} When you retrieve it from the database, just unserialize it. <?php # Select from your database ...... $selected = unserialize($result); print_r($selected); PHP: ?>[/PHP] OUTPUT:array ( [select1] => default [select2] => default [select3] => Comedy )