Jump to content

Recommended Posts

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:

 

 
$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?):

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

 

I was thinking of if function.

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

 

thanks guys

Link to comment
https://forums.phpfreaks.com/topic/143420-update-1-table-compare-2-tables-query/
Share on other sites

Why not just do this:

 

if (isset($_GET['passlocation'])) {
    mysql_query("UPDATE booking_schedule SET event_id_location_" . (int) $_GET['passlocation'] . " = '0' WHERE id = '" . (int) $_GET['id'] . "'");
}

 

I would suggest doing data checks on the $_GET, but yea. In the one you posted, without the where, every row in that table would be set to 0.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.