I have 3 post variables & i need to save those 3 variable values in single field in mysql table
below are table field details:
-------------------------------
id int(11)
name varchar(100)
country varchar(100)
details varchar(100) (this field used for store all 3 variables value)
if variable values are posted as id=1, name-steve & country=usa then needs to store as
RESULT - 1,steve,usa
now problem is all 3 variable are optional so if passed just id & name needs to store as
RESULT - 1,steve (no last comma will be store)
if passed just id & country then needs to store as
RESULT - 1,usa (no additional comma will be stored)
I have tried like:
if(isset($data['id']) || isset($data['name']) || isset($data['country']))
{
$details=$data['id'].",".$data['name'].",".$data['country'];
}
How can i achieve this in php-mysql ?