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);

$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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.