Martien van Wanrooij a écrit :
Okay... Sometimes I prefer to give a very basical answer to such questions,
but when I do so, I often get reactions like: "you are using too many words
for explaining something that could have been explained more easily" ....
but I will tell it my own way now.
Maybe, It's my fault. I don't speak english fluently.
Today it is Sunday. If you look at www.parochiebeekendonk.nl/viering.php
you will see the celebrations that have been done yesterday (Saturday) and
today (Sunday). Usually there are no more celebrations until next Saturday
so Monday is a good day to refresh the scheduling for next weekend.
But sometimes the Monday after Easterm should be shown and at Eastern I
would like to switch the re-schedulling date to Wednesday or so. Christmas
is still more complicated. It is 25th of December and it could be any day of
the week. Let us say Christmas is on a Wednesday.. since many people are on
holiday it would be good to show all the celebrations from the weekend
*before* Christmas until the weekend *after* New Years Day... but this
doesn't change the fact that generally, there is just one scheduling for the
next weekend that can be refreshed every Monday..
What I would like to create is an interface that returns the Monday before
and the Monday after unless the user indicates explicitely another value for
this monday-before and monday-after field
Martien
It's possible to store a begin/end date in a table (or in a flat file).
You just have to implement an interface to modify it.
You have to search if the values exists else you assign them the value
of the last monday and the next monday.
After that, build the request to obtain the celebrations between these 2
dates.
Note: You don't need to update the values of the "celebration" table,
juste implement an interface to add new values. So, it's possible to
store the celebrations for months in the future. They will just appear
at the right period.
For example:
<?php
$connect=mysql_connect($bd,$user,$pass);
mysql_select_db($table,$connect);
$query="SELECT begin_date,end_date FROM date_conf";
$result=mysql_query($query,$connect);
$row=mysql_fetch_array($result);
$date_begin=($row['begin_date']!='')? $row['begin_date'] :
date('Y-m-d',strtotime("last Monday"));
$date_end=($row['end_date']!='')? $row['end_date'] :
date('Y-m-d',strtotime("Monday"));
$requete="SELECT * FROM celebration where date >= $date_begin AND date
<= $date_end";
......
?>
This is not the best code for that, but it's a way to do that I think.
It depends on the build of your mysql tables
--
Manu