0

I want to update the column value(slot time) present in "schedule" table to zero time as the slot time is inserted to another table "appointment" so that the booked slot times will be set to unavailable in "schedule" tabel

<?php

$docid = $_SESSION['did'];
$date = $_SESSION['dt'];
$slot = $_SESSION['st'];

/*echo$docid;
echo$date;*/
$sql1 = "SELECT * FROM `appointment`;";
$sql2 = "SELECT * FROM `schedule`;";


$result1 = mysqli_query($conn,$sql1);
$result2 = mysqli_query($conn,$sql2);

while($rows1 = mysqli_fetch_assoc($result1)){

    if($rows1['docid']=$docid && $rows1['date']=$date){
        echo $docid;
        echo $date;
        echo $slot;
        echo "match";
        while ($rows2 = mysqli_fetch_assoc($result2)) {
            for ($i=3; $i <10 ; $i++) { 
                if ($rows2[$i]=$slot){
                    echo $rows2[$i];
                    $sql = "UPDATE `schedule` SET ________='00:00:00';"
                    mysqli_query($conn,$sql);
                    echo $i;
                    break;
                }
                
            }break;     
        }
    }
    break;
}
Meghana
  • 1
  • 1
  • 1
    Maybe `join` the other table then you'd know if there was a match.. don't forget a `where` clause on the `update`. – user3783243 Jul 24 '22 at 15:28
  • Does this answer your question? [MySQL syntax for Join Update](https://stackoverflow.com/questions/2114534/mysql-syntax-for-join-update) – Charlieface Jul 24 '22 at 15:32
  • I found the match to the column value in another table but couldn't get the respective column name – Meghana Jul 24 '22 at 15:32

0 Answers0