0

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)."');

Edited by Nybuler: n/a

3
Contributors
3
Replies
10
Views
6 Years
Discussion Span
Last Post by Nybuler
0

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')"
1

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)."')";
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.