Toribash
Original Post
lxor I NEED YOU BRO
K so asap I need to accomplish this:

I'm currently building an airline website, working on the booking system at the moment. It runs in seasons, which are added manually. When the user adds a new season they assign a start date and an end date:

season_id (a_i)
start_date
end_date

From this a flight table needs to be populated:

flight_id (a_i)
season_id
tour_id
dept_date
no_customers (defaulting to 0)

The dept_date is what is causing me problems. Three tours are hard coded into the system as follows:

tour_id
tour_name
plane
seat_price

Departing in this fashion:

Tour 1: Each Saturday, Monday & Thursday (tour_id = 1)
Tour 2: Each Sunday, Tuesday & Friday (tour_id = 2)
Tour 3: Each Saturday (tour_id = 3)

So, basically I need to take the selected start_date(season) and the selected end_date(season) and insert a flight with tour_id = 1 into every Saturday, Monday, & Thursday with tour_id = 2 into every Sunday, Tuesday & Friday and with tour_id = 3 into every Saturday between these dates.

I have no idea how to do this.

Make it happen and I'll make you rich (metaphorically speaking).
MOTHERFUCKER YOU POSTED THIS THE EXACT DAY I WENT AWAY FOR THREE DAYS GODDAMNIT TALK ABOUT BAD TIMING

okay so if I'm getting this right you need every sun,tue,fri between start_date and end_date to have its own entry in the thingo

PHP Code:
date('w'); 
will give you the day of the week in numbers, so for each date('w') between start_date and end_date where: date('w') == 0 || date('w') == 2 || date('w') == 5, you'll have to put a thingy into the table

so first, you need to figure out how many days there are between the start_date and end_date -- simple as converting to seconds and then subtracting and then dividing by 60*60*24 (= 86400)
then calculate the current day's number
FUCK IT I'LL JUST CODE IT CBA EXPLAINING
PHP Code:
$today date('w');
$days = (toSeconds($end_date) - toSeconds($start_date)) / 86400// I'm sure you can figure out toSeconds() ;)

for ($i 0$j $today$i $days$i++ && $j++ && $j %= 7// ugly shit but i'm in a hurry
{
    if (
$j == || $j == || $j == 5)
        
populateTable($blah); // tour_id = 1
// AND ETC FOR THE OTHER TOUR_IDs

i probably misunderstood something or am too late but oh well
Last edited by lxor; Nov 28, 2011 at 09:44 AM.
GOOD THING SOMEONE KNOWS CODING.

FEE WOULD SUCK LESS.


بسم الله الرحمان الرحيم


crux got something working whilst you were busy ignoring my needs as a human being.

Appreciate the help anyway, cheers.