ploppy Posted September 29, 2010 Share Posted September 29, 2010 hello in the attached code, how do i add another field to the query? ie, i have all the code to create the result and would like to add further values such as $dept? what is the correct way to code query? i must stress that i am using php 4.4.7 so json_encode is out. the code is working but just need to find a way to add the $dept to the qeury? many thanks $dept = array(); $box = array(); while ($row = mysql_fetch_array($result)) { $dept[] = $row['department']; $box[] = $row['custref']; } /*$items = rtrim($_POST['items'],","); $sql = "UPDATE `boxes` SET status = 'Out' WHERE Id IN ($items)"; $result = runSQL($sql);*/ $total = count(explode(",",$items)); $result = runSQL($sql); $total = mysql_affected_rows(); /// Line 18/19 commented for demo purposes. The MySQL query is not executed in this case. When line 18 and 19 are uncommented, the MySQL query will be executed. 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: text/x-json"); $json = ""; $json .= "{\n"; $json .= "box: [\"". implode('","', $box) ."\"]\n"; $json .= "}\n"; echo $json; $sql = "INSERT INTO `act` (`item`) VALUES ('". implode("'),('", $box) . "')"; $result = runSQL($sql); 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.