Morning,
I have this class to enter data from a form dynamically. Its works like a dream except for one little piece. I have about 5 multiple selects on my form. It keeps insert them as the word "Array"
One of the fields is like this:
<select name="CitrixApps[]" multiple>
<option value="PHP" SELECTED>PHP</option>
<option value="Perl">Perl</option>
<option value="JavaScript">JavaScript</option>
<option value="Python">Python</option>
<option value="Ruby">Ruby</option>
</select>
This is the class to insert the records:
class dbinsert{
var $i;
var $n;
var $fld;
var $val;
function gotcha($arr, $table){
$this->i = 0;
foreach($arr as $key => $value){
if($key != 'Submit'){
$this->fld[$this->i] = $key;
$this->val[$this->i] = "\"$value\"";
}
else{
break;
}
$this->i++;
}
$this->insert($table, $this->fld, $this->val);
}
function insert($table, $fld, $val){
$query = "INSERT INTO $table (%s) VALUES (%s)";
$query = sprintf($query, implode(",", $fld), implode(",", $val));
$result = mssql_query($query) or die;
}
}
This is a print from the form submission:
CitrixApps = Perl,JavaScript,Python
query = INSERT INTO tblHolding (CitrixApps,ActionRequested) VALUES ("Array","Add New User")
The word "Array" should be "Perl,JavaScript,Python" Any thoughts how I can make this happen would be greatly appreciated.
Thanks
Laura