alan.wittes Posted July 2, 2007 Share Posted July 2, 2007 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. Quote Link to comment Share on other sites More sharing options...
Dragen Posted July 2, 2007 Share Posted July 2, 2007 try printing AG_LANGUAGE before imploding it and see what you get. Also echo $language and see what it is. if it says array, print the array and let me know what it is: <?php print_r($_POST['AG_LANGUAGE']); $language = (!empty($_POST['AG_LANGUAGE'])? implode(',',$_POST['AG_LANGUAGE'])."\n" : ''); echo '<br />' . $language; ?> Quote Link to comment Share on other sites More sharing options...
tapos Posted July 2, 2007 Share Posted July 2, 2007 You can use a special character when u emplode the variable. and when u retrive from mysql u can use explode to get an array. ........ Tapos Pal Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.