This is my update.php file I am unable to update my data in database. I have also attached a error screenshot which I have faced at the time of updating the data.
I not able to fetch data perfectly on update.php page.
update.php
<?php
include('config.php');
$update_record=$_GET['update'];
$query="select * from form_sql where id='$update_record' ";
$run=mysqli_query($conn, $query);
while ($row=mysqli_fetch_array($run))
{
$fname=$row['fname'];
$lname=$row['lname'];
$country=$row['country'];
$subject=$row['subject'];
$hobbies=$row['hobbies'];
$gender=$row['gender'];
}
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h3>Update Form</h3>
<div class="container">
<form name="sql" action="update.php" method="GET">
<label for="fname">First Name</label>
<input type="text" name="fname" placeholder="Your name.." value="<?php echo $fname; ?>" required>
<label for="lname">Last Name</label>
<input type="text" name="lname" placeholder="Your last name.." value="<?php echo $lname; ?>" required>
<label for="country" name="country" value="<?php echo $country; ?>" >Country</label>
<select id="country" name="country">
<option value="australia">Australia</option>
<option value="canada">Canada</option>
<option value="usa">USA</option>
</select>
<label for="subject">Comments</label>
<textarea id="subject" name="subject" placeholder="Write something.." style="height:200px" value="<?php echo $subject; ?>" required></textarea>
<br>
<br>
<label for="Hobbies">Hobbies</label>
<br>
<input type="checkbox" name="hobbies[]" value="playing">Playing<br>
<input type="checkbox" name="hobbies[]" value="music">Music<br>
<input type="checkbox" name="hobbies[]" value="dane">Dancing<br>
<br>
<label for="gender">Gender</label>
<br>
<input type="radio" name="gender" value="Male">Male
<input type="radio" name="gender" value="Female">Female<br>
<input type="submit" value="Update" name="update">
</form>
</div>
</body>
</html>
view.php
This is my view.php file I am unable to update my data in dataabse.
<?php
include('config.php');
$result = mysqli_query($conn, "SELECT * FROM form_sql");
?>
<html>
<head>
</head>
<body>
<?php
echo "<table width='100%' border='1'>
<tr>
<td><strong>First Name</strong></td>
<td><strong>Last Name</strong></td>
<td><strong>Country</strong></td>
<td><strong>Comments</strong></td>
<td><strong>Hobbies</strong></td>
<td><strong>Gender</strong></td>
<td><strong>Edit</strong></td>
<td><strong>Delete</strong></td>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>".$row['fname'] ."</td>";
echo "<td>".$row['lname'] ."</td>";
echo "<td>".$row['country']."</td>";
echo "<td>".$row['subject']."</td>";
echo "<td>".$row['hobbies']."</td>";
echo "<td>".$row['gender']."</td>";
echo "<td><a href="update.php?id=$row[Id]">Update</a></td>";
echo "<td><a href=\"delete.php?id=$row[Id]\">Delete</a></td>";
echo "</tr>";
}
echo "</table>";
?>
</body>
</html>