こんにちはみんな私は学生の詳細を更新するstudent_edit.phpファイルがあるプロジェクトに取り組んでいますすべてのデータは正常に更新されましたが、更新時に1つの問題があり、すべてではなく2つのフィールドしか言わず、画像が空白になり、フィールドが空白になります更新成功。
私がやっていることは、学生の写真を見せていることです。それに加えて、画像を閲覧して画像を更新するための別の入力フィールドがあります。私が欲しいのは、代わりに画像を更新していない場合、他のフィールドの画像を更新しても、空白にならないようにすることです。
必要なコード スニペットは次のようになります。
<?php
$file_name = $_FILES['picture']['name'];
$tmp_name = $_FILES['picture']['tmp_name'];
if (copy($tmp_name, "images/" . $file_name)) {
$picture = "images/" . $file_name;
}
if (!isset($_POST['picture'])) {
$res = mysql_query("UPDATE student SET `id`='$id',`branch_id`='$branch_id',`class_id`='$class_id',`section_id`='$section_id',`roll_number`='$roll_number',`student_name`='$student_name',`father_name`='$father_name',`dob`='$dob',`student_address`='$student_address',`gender`='$gender',`status`='$status',updated=now() WHERE id='$id'") or die(mysql_error());
}
else {
$res = mysql_query("UPDATE student SET `id`='$id',`branch_id`='$branch_id',`class_id`='$class_id',`section_id`='$section_id',`roll_number`='$roll_number',`student_name`='$student_name',`father_name`='$father_name',`dob`='$dob',`student_address`='$student_address',`gender`='$gender',`status`='$status',`picture`='$picture',updated=now() WHERE id='$id'") or die(mysql_error());
}
?>
そして、それらは私がpicsと呼ぶ画像領域です
<p>
<label for="picture"><strong>Picture:</strong> </label>
<a href="#"><img src="<?php echo $rec['picture'];?>" width="100" height="100"/></a>
<input name="picture" type="file" value="">
</p>
そして、それらは私がpicsと呼ぶ画像領域です
<p>
<label for="picture"><strong>Picture:</strong> </label>
<a href="#"><img src="<?php echo $rec['picture'];?>" width="100" height="100"/></a>
<input name="picture" type="file" value="">
</p>