Page 1 of 1

3 textfields (several words inside) - make 1 PHP variable ??

Posted: Tue Jan 27, 2004 2:37 pm
by Calimero
If I have 3 textfields in a form named: tf1, tf2 and tf3, and user inserts some words inside each (lets say 3 or more), whats the PHP code to make all 3 textfields, all words inside - together to be inserted in one MySQL field, NOTE Sql code I know how to write, if all those ex. 9 words can be represented as one variable...

Anyone, help,... And of course THANK YOU :D

Posted: Tue Jan 27, 2004 2:42 pm
by Straterra
You could concatinate (forgive my spelling). This simply means to add 2 string together. I would add the strings together, and put a special character inbetween each string, so you know how to get eat string by its self again. To add two strings together, you just use the period (.) .

Posted: Tue Jan 27, 2004 3:37 pm
by vigge89

Code: Select all

<?php
$together = $field1.$field2.field3;
// you can also do
$together = "$field1 $field2 field3";
//or implode them 
$fields = array ($field1, $field2, $field3);
$separator = "||"; //separe each piece with two |'s
$together = implode($separator, $array)
?>