I am trying design a form which involves a drop down list. I would like to edit the form by changing the value of the variables in the form. I have retrieved all the values from mysql DB, but when I click the submit button without changing the value in the dropdown list. The value will be set to null.
if(isset($_POST['update'])){
$update_id = $_GET['edit_form'];
$post_title1 = $_POST['title'];
$post_date1 = date("Y-m-d");
$post_author1 = $_POST['author'];
$post_keywords1 = $_POST['keywords'];
$post_type1 = $_POST['category']; // This is the content I want to update but was set to null, the rest is fine.
$post_content1 = $_POST['content'];
$post_image1 = $_FILES['image']['name'];
$image_tmp = $_FILES['image']['tmp_name'];
}}
This is my dropdown list:
<html>
<select name="category" class="err">`enter code here`
<option value=""><?php echo $post_type;?></option>
<option value="Class">Class</option>
<option value="Facilities">Facilities</option>
<option value="Services">Services</option>
</select>
What I want is when I click the submit button without changing the content of the post, the
$post_type1
will not be set to null, but keep its original value from DB.
Thanks, hope I have stated my question clearly:)
Here's the code that builds the db query :
$post_image1 = $_FILES['image']['name'];
move_uploaded_file($image_tmp,"../images/$post_image1");
$update_query = "UPDATE post SET post_title='$post_title1', post_date='$post_date1', post_author='$post_author1', post_image='$post_image1', post_keywords='$post_keywords1',post_type='$post_type1',
post_content='$post_content1' WHERE post_id ='$update_id'";