Greeting to all :)

i wanted to store a selected option in to mysql database
My senior said must in this format"
option 1
option 2
option 3

I was stuck with this couple hours ago!
i have think of nl2br but i'm not familiar with it
Can anyone help?

here my code for the html:

<select id="inform_relevant_person" name="pic_option[]"size="10" multiple="multiple">
	  <option value="0449" selected>0449</option>
	  <option value="1250" selected>1250</option>
      <option value="1434" selected>1434</option>
        </select>

this is in a post method from where the form action are testing.php

testing.php:

$pic_staffcode = $_POST[pic_option];
	var_dump($pic_staffcode);
	foreach($pic_staffcode as $value){$pic_staffcodeS = "'".$pic_staffcodeS."'" . $value."\n";}

i know here the problem ! ut i dono how to solve

here the continue of testing.php

$qryInsertLeaveApplication = "INSERT INTO global_leave_replacement_application (pic_staffcode)VALUES('".nl2br($pic_staffcode)."');

What for would you need nl2br when storing the values? You need this function to display line breaks in HTML, not to store them in the database. Use

INSERT INTO global_leave_replacement_application (pic_staffcode) VALUES ('$pic_staffcodeS')"

You need implode function.Which will bing array into string with comma ",".

$qryInsertLeaveApplication = "INSERT INTO global_leave_replacement_application (pic_staffcode)VALUES('".implode(',',$pic_staffcode)."')";

^^ Thx a lot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.