私はanglejs PHPフォームポストを使って行を挿入または更新しています。現在、以下の作業例があります。これを短時間で記述できるかどうかを知りたいので、UPDATEとINSERTの両方のシナリオで使用できます。私は定義された値だけでなくフォーム全体を提出したい。手伝ってくれてありがとう。PHP MYSQLでPOST FORMを短くする
function update($con){
$postdata = file_get_contents("php://input", true);
$request = json_decode($postdata);
$idx = $request->idx;
$images = $request->images;
$collection = $request->collection;
$title = $request->title;
$description = $request->description;
$height = $request->height;
$width = $request->width;
$length = $request->length;
$weight = $request->weight;
$price = $request->price;
$availability = $request->availability;
$active = $request->active;
$method = $request->method;
$searchkeys = $request->searchkeys;
$materialused = $request->materialused;
if(is_array($images)){
$implodeImg = implode(',', $images);
}else{
$implodeImg = $images;
}
$sqlIn = "UPDATE prodList_1 SET
idx = '$idx',
images = '$implodeImg',
collection = '$collection',
title = '$title',
description = '$description',
height = '$height',
width = '$width',
length = '$length',
weight = '$weight',
price = '$price',
availability = '$availability',
active = '$active',
method = '$method',
searchkeys = '$searchkeys',
materialused = '$materialused'
WHERE idx = '$idx'";
if (mysqli_query($con, $sqlIn)) {
echo "Record Updated successfully";
} else {
echo "Error: " . $sqlIn . "<br>" . mysqli_error($con);
}
}
ありがとうMikey、私はこれをやらなければならないことに気がついたとき、同じ感じがしましたが、私がmysql php admin databaseと共有ホスティングしている場合のオプションは何ですか。私はあなたの提案を実装しようとし、それがどのように行くかを見てみましょう。 – alflashy
共有ホスティングに[PDO](http://php.net/manual/en/book.pdo.php)がインストールされていることを確認してください。私は、ホスティングプロバイダの多くが、現在広く使われているように、これを持っていると信じています。 PDOにはもっと多くの機能があり、個人的にははるかに使いやすくなっています。 – Mikey
ありがとうMikey、私はそれをチェックします – alflashy