PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$_GET['s_cell[]'] is an array. So you will have to walk through it to 'mount' query string. But how will you SET s_cell to more than one value? Will it be a sum or something?
The array is coming from a list box where the client can choose up to 11 selectable items, which are words. I want to put those words, which are selected by the client, into a MySQL column for that record.
The array is produced just fine, however, I having difficulty passing it to the MySQL database.
It would seem, I need to put the array in some sort of string, but knowing how to do that and where to put it in the script is at the moment beyond my expertise.
Came across the suggestion else where that I probably need to serialize the array. I just wish there was a tutorial showing how to do all of this. I can't believe there's so little information regarding php and multiple select menu boxes.
Tutorial?
If you can explain further, we could whip one up. But as far as I know, my above idea would be sufficient.
serialize() alone is not good, as it produces " (double quotes) that wont work well with database queries. There are many solutions to remove them, but I think that adding base64_encode() is easy enough.
<?php if($Submit == "Submit") /* Activated by clicking the form button "Submit." */
{
foreach ($scell as $groups)
{
$array_data .= $groups."," ; /* Puts the contents of the array into a variable. */
}
$array_data = substr($array_data,0,-1); /* Removes the last character in the variable "comma." */
$db = mysql_select_db($database_Ekklesia, $Ekklesia);
$query = "UPDATE laos SET scell='$array_data' WHERE id='$ID'";
$result = mysql_query($query) or die ("Couldn't execute query.");
}?>
In regards to the tutorial, the problem is that many are having a problem with knowing what to do with multiple select menus in forms because Dreamweaver's automatic application of php scripts wont properly create a script that works. Even on the Dreamweaver forums, questions go unanswered because know one seems to know what to do. If some did write a tutorial I know many would benefit greatly.