...

View Full Version : multiple update where clause table



helenp
01-13-2012, 02:04 PM
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

$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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum