Angel's Wing's
Angel's Wing's

Reputation: 105

How combine value to be one from multiple textbox php before insert to mysql

How get value to one field from multiple textbox?

i have example 3 textbox

<input name="post_code[]" class="input form-control" id="tbCode1" placeholder="Code 1" type="text" value="A01">
<input name="post_code[]" class="input form-control" id="tbCode2" placeholder="Code 2" type="text" value="A02">
<input name="post_code[]" class="input form-control" id="tbCode3" placeholder="Code 3" type="text" value="A03">

but how make the value like this

$postcode = 'A01,A02,A03';

before insert to mysql

Upvotes: 1

Views: 1109

Answers (2)

Shailesh Katarmal
Shailesh Katarmal

Reputation: 2785

$a = implode(",", $_POST['post_code']);
echo $a;

Upvotes: 0

momouu
momouu

Reputation: 711

Use implode()

$post_code = $_POST['post_code'];
$postcode = implode(",",$post_code);

Upvotes: 1

Related Questions