I am looping through the rows of the database with fetch_assoc() and I am selecting two columns of it. I check the values of these two columns of each row. If they are between 2 values then I updated a third row as 1(TRUE) if a statement is true. I am creating two connections because there are two statements, the one that selects the information and the other that updates the column that I want to be updated. When I try to print the information in the screen it seems that the SELECT statement works but when I try to UPDATE the column that I want the UPDATE statement does not update the database. Here is my code:
$conn= mysqli_connect("localhost","root","root");
$variablech = 1 ;
$query = "SELECT Client, Info FROM DataTable";
if ($result = mysqli_query($conn, $query)) {
while($row=mysqli_fetch_row($result)) {
if((($row['Client']>=54.055) && ($row['Client']<=54.117) ) && (( $row['Info']>=-4.827) && ( $row['Info']<=-4.317)))
{
$variablech = 0;
$sql= " UPDATE DataTable SET InfoData='$variablech' WHERE Client='".$row['Client']."' AND Info='".$row['Info']."'";
$conn->query($sql);
echo "yes";
}
else
{
$variablech = 1;
$sql= " UPDATE DataTable SET InfoData='$variablech' WHERE Client='".$row['Client']."' AND Info'".$row['Info']."'";
$conn->query($sql);
echo "no";
}
}
}