So I want to fetch my data from Database and be able to display and update it. Im on the part where I have to display a value from the db on a Dropdown but only the first option of the dropdown is being displayed.
Below is complete code.
<?php
mysqli_connect('localhost', 'root', '');
mysqli_select_db('storm');
$_GET['id'];
$ssh = $_GET['ssh'];
$_GET['provi'];
$_GET['impact'];
$_GET['advice'];
$_GET['date'];
$_GET['typhoon'];
$_GET['warning'];
?>
<html>
<body>
<div class="container">
<form action="edit.php" method="post">
<div class="form-group">
<label for="prov">Provinces</label><br>
<select id="prov" class="form-control" type="text" name="provi1">
<option value="Isabela"><?php echo $_GET['provi'];?></option>
<option value="La Union"><?php echo $_GET['provi'];?></option>
<option value="Pangasinan"><?php echo $_GET['provi'];?></option>
<option value="Ilocos Sur"><?php echo $_GET['provi'];?></option>
<option value="Ilocos Norte"><?php echo $_GET['provi'];?></option>
</select>
</div>
<div class="form-group">
<label>Date</label><br>
<input class="w3-input w3-border form-control" type="date" name="date" value="">
</div>
<div class="col-md-6">
<div class="form-group">
<label>Typhoon Name</label><br>
<input type="text" name="typhoon" value="<?php echo $_GET['typhoon']; ?>" class="form-control">
<input type="hidden" name="id" value="">
</div>
<div class="form-group">
<label>Warning #</label><br>
<input type="text" name="warning" value="<?php echo $_GET['warning']; ?>" class="form-control">
</div>
</div>
<div class="col">
<div class="form-group">
<input class="btnSubmit" type="submit" value="Update" name="submit" style="background-color: #408cff;">
<input class="btnSubmit" type="reset" value="Cancel" style="background-color: #de5959;">
</div>
</div>
</form>
<?php
if(isset($_GET['submit'])){
$id = $_GET['id'];
$ssh = $_GET['ssh'];
$muni = $_GET['muni'];
$impact = $_GET['impact'];
$advice = $_GET['advice'];
$date = $_GET['date'];
$typhoon = $_GET['typhoon'];
$warning = $_GET['warning'];
$query = "UPDATE twothree SET ssh='$ssh', muni='$muni', impact='$impact', advice='$advice', date='$date', typhoon='$typhoon', warning='$warning' WHERE id='$id'";
$data = mysqli_query($conn, $query);
if($data){
echo "Record Updated Successfully!";
}else{
echo "Record Not Updated.";
}
}
?>
I'm pretty sure that I am doing something wrong. Hope you guys figure it out for me. I'm new to this and I hope that I can learn from you guys. Thanks.