Jump to content

Get select multiple options into one variable.


regoch

Recommended Posts

Hi! I got this script for inserting jobs from multiple select, but can not get it work. I wonna all data from "select info_dodatni_posao" to get in one variable and put it in mysql database. I try this way thats below but not working! Any ideas? When I remove [] i get it to put just one job in mysql even if i select 3 or more.

 

test.html

<select multiple="multiple" name="info_dodatni_posao[]" id="info_dodatni_posao[]">
<option value='Certified Beauty Therapist'>Certified Beauty Therapist</option><option value='Certified Dive Master'>Certified Dive Master</option><option value='Certified Diver'>Certified Diver</option><option value='Certified Hair Dresser'>Certified Hair Dresser</option><option value='Certified Personal'>Certified Personal</option></select>

test.php

$info_id = $_POST['info_id'];
$info_dodatni_posao = $_POST['info_dodatni_posao[]'];
$qry = "UPDATE tz_info SET  info_dodatni_posao='$info_dodatni_posao' WHERE info_id='$info_id'";
$result = @mysql_query($qry);

Link to comment
Share on other sites

$info_id = $_POST['info_id'];
$info_dodatni_posao = join(", ", $_POST['info_dodatni_posao']);
$qry = "UPDATE tz_info SET  info_dodatni_posao='$info_dodatni_posao' WHERE info_id='$info_id'";
$result = @mysql_query($qry);

 

I add join() in second line and get all multiple post in one field in database with , between like this

Full Time, Full Time Rotational, Freelance

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.