Sujan Shrestha Sujan Shrestha - 5 months ago 9
SQL Question

How to join multiple column values into one column while inserting

I have a table which looks like this:

ID | Name | Address


I have a form which looks like this:

<input type="text" class="form-control" name="name"/>
<input type="text" class="form-control" name="address"/>


My PHP Code:

$name = $_POST['name'];
$address = $_POST['address'];
$sql = "Insert into staff(client_name,address) VALUES ('$client_name','$address')";
$this->db->query($sql);


What i want to do is, join the values posted by user into one column.i.e if user types JOHN in Name field and USA in address field.
I want to following in my database table

ID | Name | Address
1 | JOHN USA | USA

Answer

use thomething like this:

$sql = "Insert into staff(client_name,address) VALUES ('$client_name $address','$address')";