私のデータベースにはいくつかのテーブルがあり、画像パス用に 1 つ、画像幅用に 1 つあり、NULL の標準値と null 値 (チェックボックスとドロップダウン ボックスは両方とも NULL) を持っています。新しいパスまたは幅は変更されませんが、他のパスは変更されます。これは私のコードです。
require_once("../Packages/Connection.php");
$text = mysql_real_escape_string($_POST["articleText"]);
$method = $_POST['method'];
$articleId = $_POST['articleId'];
$imagePath = $_POST['imagePath'];
$imageWidth = $_POST['imageWidth'];
if($method == "update")
{
mysql_query("UPDATE Articles SET text='$text' WHERE id='$articleId'") or die(mysql_error());
}
elseif($method == "delete")
{
mysql_query("DELETE FROM Articles WHERE id=".$articleId."");
};
if($_POST["articleGroup"]=="News")
{
mysql_query("INSERT INTO Articles VALUES(NULL,'".$_POST["articleGroup"]."','".time()."','".$text."', NULL, NULL, NULL)") or die(mysql_error());
}
else
{
mysql_query("INSERT INTO Articles VALUES (NULL,'".$_POST["articleGroup"]."','NULL','".$text."','NULL','".$imagePath."','".$imageWidth."')") or die(mysql_error());
}
前もって感謝します