update 1 table by comparing 2 tables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
knightsjoker
Forum Newbie
Posts: 13
Joined: Fri Dec 26, 2008 2:00 am

update 1 table by comparing 2 tables

Post by knightsjoker »

Hi guys,

I'm stump on how to do this. Basically I'm trying to update 1 table by comparing values from different tables.

here's how i set it up:

Code: Select all

 
$query = "SELECT booking_event.starting_date_time, booking_schedule.schedule_date_time ".
 "FROM booking_event, booking_schedule ".
    "WHERE booking_event.starting_date_time = booking_schedule.schedule_date_time";
 
with that part set...
i want to update a different field which is event_id_location_# (there are 20 locations)
I want to update just certain location according to the schedule_date_time

so let's say location 1 has a value of 1 (occupied) I want to update it to 0 (not occupied)

how do I go about doing this? I already passed the hidden value of location (is it correct?):

Code: Select all

 
<a href=\"delete.php?id={$row[id]}&passlocation={$getlocation}\">Delete</a>"; ?>
 
I was thinking of if function.

Code: Select all

 
while($row = mysql_fetch_array($query))
{
    if (location == loc1)
    {
        query2="UPDATE booking_schedule SET event_id_location_1 = '0'";
    }
}
 
thanks guys
Post Reply