I try to update multiple data but I get stuck for update. how my page look like and here my coding
$querydevice = "SELECT * FROM device WHERE email = '".$_SESSION['email']."'";
$con = mysqli_query($con, $querydevice);
while ( $row=mysqli_fetch_assoc($con)) {
$series_no=$row['series_no'];
$latitude=$row['latitude'];
$longitude=$row['longitude'];
echo"<tr>";
echo"<td>".$row['series_no']."</td>";
echo"<td><input type='text' name='latitude' id='latitude' value='".$row['latitude']. "' ></td>";
echo"<td><input type='text' name='longitude' id='longitude' value='".$row['longitude']. "' ></td>";
echo"</tr>";
}
My update button and I not really sure this is coding is right.
session_start();
include("config.php");
for($i=0;$i<$row;i++) {
$sql1 = "UPDATE device SET latitude='$latitude', longitude='$longitude' CASE series_no='$series_no'";
if(mysqli_query($con,$sql1)) {
echo "<script type=\"text/javascript\">alert('Coordinata updated');window.location.href='device.php';</script>";
}
else {
echo "Error:" . $sql . "<br>" . mysqli_error($con);
}
}
mysqli_close($con);
In your first code, you had not included config.php file. You are using the connection variable $con for storing the result of query also. In the second file you are using "$series_no" which is in the first file.