Hi, I am new in Php. Please Help me to short out this problem
I am trying to use a status button in a table raw when click the status button then only update the status field in database. and when click the status button all raw is submitted.
I am writing this code below
guest.php
<!DOCTYPE html>
<?php
include 'connect.php';
?>
</br></br>
<h4><b>Guest Status </b></h4>
<div class="row">
<div class="panel-body" style="height: auto;">
<form class="form-horizontal" role="form" action="guestExe.php" method="POST">
<div class="form-group">
<div class="panel-body" style="height: auto; padding:5px;">
<div class="col-md-12" >
<label for="name" class="col-md-3 control-label">Name:</label>
<div class="col-md-3">
<input type="text" class="form-control" id="name" name="name" >
</div>
<label for="mobileNo" class="col-md-3 control-label">Mobile No:</label>
<div class="col-md-3">
<input type="text" class="form-control" id="mobileNo" name="mobileNo">
</div>
</div>
</div>
<div class="panel-body" style="height: auto; padding:5px;">
<div class="col-md-12">
<label for="email" class="col-md-3 control-label">E mail:</label>
<div class="col-md-3">
<input type="text" class="form-control" id="email" name="email" >
</div>
</div>
</div>
</div>
<div class="panel-body" style="height: auto;">
<div class="col-sm-12">
<button type="submit" name="submit" class="btn btn-warning" > SUBMIT</button>
</div>
</div>
</form>
</div>
</div>
<table class="table table-bordered" style="width:100%; border:2px solid red;">
<thead >
<tr style="background-color:red;">
<th>SL/NO</th>
<th>Name</th>
<th>MobileNo</th>
<th>E-mail</th>
<th>Status</th>
<!--<th>Edit</th>
<th>Delete</th> -->
</tr>
</thead>
<tr>
<?php
$result = mysqli_query($con,"SELECT * FROM guest");
while($row = mysqli_fetch_array($result ))
{
echo '<tr>
<td>'.$row['Id'].'</td>
<td>'.$row['name'].'</td>
<td>'.$row['mobileNo'].'</td>
<td>'.$row['email'].'</td>' ?>
<td><button class="btn waves-effect waves-light right" type="submit" name="status" value="OK"> APPROVE </button></td>
</tr><?php
}
?>
</tbody>
</table>
guestExe.php
<!DOCTYPE html>
<head> <title>ABC</title></head>
<body>
<?php
//error_reporting('1');
include 'connect.php';
if(isset($_POST['submit']))
{
$name = $_POST['name'];
$mobileNo = $_POST['mobileNo'];
$email = $_POST['email'];
$sql = "INSERT INTO
guest(name,mobileNo,email) VALUES ('$name','$mobileNo','$email')";
if(!mysqli_query($con, $sql))
{
die('conection failed'.mysqli_error($con));
}
else
{
echo "SUccsesively Enter";
}
}
header('Location: guest.php');
?>
</body>
</html>