Add value to database query

assifyill

New Member
I would like to add another value to an \[code\]INSERT\[/code\] statement, but whatever I do, it causes various errors. Can someone show me the correct way to code this?My original working code is this:\[code\]$sql = "INSERT INTO `act` (`department`) VALUES ('". implode("'),('", $dept) . "')";\[/code\]I have tried amongst others:\[code\]$sql = "INSERT INTO `act` (`department`,`item`) VALUES ('". implode("'),('", $dept) . "','". implode("'),('", $box) . "')";\[/code\]Perhaps I should post my code that produces the result: \[code\]$dept = array();$box = array();while ($row = mysql_fetch_array($result)) { $dept[] = $row['department']; $box[] = $row['custref'];}header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" );header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" );header("Cache-Control: no-cache, must-revalidate" );header("Pragma: no-cache" );header("Content-type: application/json");$json = "";$json .= "{\n";$json .= "dept: [\"". implode('","', $dept). "\"],\n";$json .= "box: [\"". implode('","', $box) ."\"]\n";$json .= "}\n";echo $json;$sql = "INSERT INTO `act` (`department`) VALUES ('". implode("'),('", $dept) . "')";$result = runSQL($sql);\[/code\]
 
Back
Top