I want to create a php code which can update all the rows at once when i click the button. Already try few method that i look from the other post but still can't figure it out. Please help me................
<table cellspacing="0" cellpadding="1" border=1px; action="" method="post">
<?php
$result=mysqli_query($conn,"SELECT * from subject ");
if($result->num_rows>0)
{
?>
<tr>
<th>Subject Code</th>
<th>Subject</th>
<th>Fees</th>
<th>Status</th>
</tr>
<?php
while($row = mysqli_fetch_assoc($result))
{
if ($row["subject_status"]==="Available")
{$status="Unavailable";}
else $status="Available";
?>
<tr class="alttr1">
<td><?php echo $row["subject_code"]; ?></td>
<td><?php echo $row["subject_name"]; ?></td>
<td>RM<input type="number" name="price[]" value="<?php echo $row["subject_price"]; ?>" ></td>
<td><select name="status[]" ><option value="<?php echo $row["subject_status"]; ?>" ><?php echo $row["subject_status"]; ?></option><option value="<?php echo $status; ?>" ><?php echo $status; ?></option></select></td>
</tr>
<?php
}
?>
</table>
<input type="submit" name="updatebtn" value="Save Changes">
<?php
if (isset($_POST["updatebtn"]))
{
$price = $_POST["price"];
$status = $_POST["status"];
foreach($_POST["price"] as $price)
{
mysqli_query($conn,"UPDATE subject SET subject_price='$price' ");
}
foreach($_POST["status"] as $status)
{
mysqli_query($conn,"UPDATE subject SET subject_status='$status' ");
}
header("location: subjectmanage.php");
}