Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Oct 2011
    Posts
    65
    Thanks
    1
    Thanked 0 Times in 0 Posts

    multiple update where clause table

    Hi,
    I have a calendar table wich have rows for 20 years at this moment.
    When I add a new property I add dates from present year (now) until year 2032.

    The problem is that after I inserted the dates with the name of property I have to update the rows with information as prices, season etc for the choosen dates in all years. So how to do it without having a huge amount of updates?
    I dont know a way to do where cal_date beween date1 and date2, and date3 and date4 and date 5 and 6 and property= 'property1' etc.....maybe there is a way.

    Also If possible I would like not to change the updatecode, as I can have a multiple selectbox to select years to update, or select several years in diferent boxes etc....the problem is the mysql select, its always best not to touch a working code.

    Maybe is possible to do something combining mysql with php to get the years from start of present year until end 2032 and then update the rows those years from php and days and months as choosed in a form.

    Don´t know where to start to search how to do it.

    Anyway, these are the updates for 2 years for high season, imagine to do it for 20 years
    Code:
    $query = mysql_query("UPDATE calendar_table SET startdate=2012-07-01, enddate=2012-08-31
    WHERE cal_date=2012-07-01 and property='$property2'");
    $query = mysql_query("UPDATE calendar_table SET startdate=2013-07-01, enddate=2013-08-31
    WHERE cal_date=2013-07-01 and property='$property2'");
    $query = mysql_query("UPDATE calendar_table SET price_client='$price_client',
      price_owner='$price_owner', price_client_week='$price_client_week',
      price_owner_week='$price_owner_week', description='$description', elena='$elena', elena_n='$elena_n', minimo='$minimo' 
      WHERE cal_date between 2012-07-01 and 2012-08-31 and property='$property2'");
    $query = mysql_query("UPDATE calendar_table SET price_client='$price_client',
      price_owner='$price_owner', price_client_week='$price_client_week',
      price_owner_week='$price_owner_week', description='$description', elena='$elena', elena_n='$elena_n', minimo='$minimo' 
      WHERE cal_date between 2013-07-01 and 2013-08-31 and property='$property2'");
    header ("Location: precios_propiedades_uno.php?property=$property2");
    Any ideas?
    Thanks,
    Helen
    Last edited by helenp; 01-13-2012 at 01:17 PM.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •