I have a problem that in my sql is always updating the last records. I need to loop in every row and update each record in that row i tried this code underneath but only last record is updating .
<tr>
<td value="<?php echo $_SESSION['flowertypename'];?>"><?php echo $_SESSION['flowertypename']?></td>
<?php
$query7 = "SELECT * FROM tbl_try WHERE country='$_SESSION[country]' AND name='$_SESSION[flowertypename]'";
$result7= mysqli_query($conn, $query7) or die("Error in query: ". mysqli_error($conn));
while ($row = mysqli_fetch_assoc($result7))
{
?>
<td><input type="number" name="reg_smallprice" value="<?php echo $row['price_small'];?>"></td>
<td><input type="number" name="reg_mediumprice" value="<?php echo $row['price_medium'];?>"></td>
<td><input type="number" name="reg_largeprice" value="<?php echo $row['price_large'];?>"></td>
<?php
}
}
?>
</tr></table>
<div class="form-group">
<div class="col-sm-offset-5 col-sm-10">
<button type="submit" name="updated" class="btn btn-default">Save Changes</button>
</div>
</div>
<?php
if(isset($_POST['updated']))
{
$query33 = "SELECT * FROM tbl_try WHERE country ='$_SESSION[country]'";
$result33 = mysqli_query($conn, $query33) or die("Error in query: ". mysqli_error($conn));
$result33_rows = mysqli_num_rows($result33);
for($x = 0; $x <= $result33_rows; $x++){
$x++;
$smallprice= mysqli_real_escape_string($conn,$_POST["reg_smallprice"]);
$mediumprice= mysqli_real_escape_string($conn,$_POST["reg_mediumprice"]);
$largeprice= mysqli_real_escape_string($conn,$_POST["reg_largeprice"]);
$query44 = "UPDATE tbl_try SET price_small = '$smallprice' ,price_medium='$mediumprice' ,price_large='$largeprice' WHERE name='$_SESSION[flowertypename]' ";
$result44 = mysqli_query($conn, $query44)
or die("Error in query: ". mysqli_error($conn));
}
echo "Registered Successfully";
header("location:trytest.php");
}
?>
<?php
require_once("footer.php");
?>
Any suggestions ??