I am using PHP to take data from an HTML input form to a MYSQL database. I have an issue with one of my fields. The field is 'Language'.
Here is what I am after: I need to have multiple 'Language' checkboxes, so that the user can check all the Languages they speak (could often be more than 1). For example, let's say the user selects 'Spanish' and 'Italian'. I would then like to store this value in my MYSQL database as 'Spanish, Italian'.
Below is my code as it stands today:
HTML Code:
<input name="AG_LANGUAGE[]" type="checkbox" value="Spanish" /> Spanish
<input name="AG_LANGUAGE[]" type="checkbox" value="Italian" /> Italian
PHP Code:
<?php
$language = (!empty($_POST['AG_LANGUAGE'])? implode(',',$_POST['AG_LANGUAGE'])."\n" : '');
?>
The problem I'm having is that the input data is being stored in my Language table field as 'Array'. Is there a way to store the actual values in the field instead (ex. 'Spanish, Italian')? If not, how do I extract the actual values using SQL? Writing a simple SQL query produces the below result:
select ag_language
from ag_profile
'Array'
Thanks in advance for any help.
Here is what I am after: I need to have multiple 'Language' checkboxes, so that the user can check all the Languages they speak (could often be more than 1). For example, let's say the user selects 'Spanish' and 'Italian'. I would then like to store this value in my MYSQL database as 'Spanish, Italian'.
Below is my code as it stands today:
HTML Code:
<input name="AG_LANGUAGE[]" type="checkbox" value="Spanish" /> Spanish
<input name="AG_LANGUAGE[]" type="checkbox" value="Italian" /> Italian
PHP Code:
<?php
$language = (!empty($_POST['AG_LANGUAGE'])? implode(',',$_POST['AG_LANGUAGE'])."\n" : '');
?>
The problem I'm having is that the input data is being stored in my Language table field as 'Array'. Is there a way to store the actual values in the field instead (ex. 'Spanish, Italian')? If not, how do I extract the actual values using SQL? Writing a simple SQL query produces the below result:
select ag_language
from ag_profile
'Array'
Thanks in advance for any help.