Veritabanı sorgu değer katacak

0 Cevap php

Ben bir INSERT açıklamada başka bir değer eklemek istiyorum, ama ne olursa olsun, çeşitli hatalara neden olur. Birisi bana bu kodu doğru yolu gösterebilir misin?

Benim orjinal çalışma kodu şudur:

$sql = "INSERT INTO `act` (`department`) VALUES ('". implode("'),('", $dept) . "')";

Ben diğerleri arasında denedim:

$sql = "INSERT INTO `act` (`department`,`item`) VALUES ('". implode("'),('", $dept) . "','". implode("'),('", $box) . "')";

Belki sonuç üretir kodumu göndermek gerekir:

$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);

0 Cevap