Hi guys,
I require some help, i got a script which is reading from a text file.
Can someone help me how to change it to get data from a text file to data from a database.
this is the current code for data from a text file:
$filecontents = file_get_contents('http://example.com/bookings.txt');
$rows = split("\n", $filecontents);
$filepart = '';
$booking_pilots = array();
$booking_controllers = array();
foreach ($rows as $row) {
if (substr($row,0,1) == '!') {
$filepart = substr($row,1);
} else {
switch (trim($filepart)) {
case 'ATC':
$fields = split(":", $row);
if (substr($fields[0],0,strlen($countryicao)) == $countryicao) {
switch (substr($fields[6],0,8)) {
case DateAdd(0):
if (!isset($booking_controllers[0])) { $booking_controllers[0] = array(); }
array_push($booking_controllers[0], $fields);
break;
case DateAdd(1):
if (!isset($booking_controllers[1])) { $booking_controllers[1] = array(); }
array_push($booking_controllers[1], $fields);
break;
case DateAdd(2):
if (!isset($booking_controllers[2])) { $booking_controllers[2] = array(); }
array_push($booking_controllers[2], $fields);
break;
}
}
break;
}
}
}
In my database i have a datafield which has datas like 2010-10-15.
Can someone help me to make the code to get the same result as above but then for data from a database.
i got a site with a specific colomn for trainings and exams.
all exams for today will be shown under header 'Today'
And all exams for tomorrow will be shown under header 'Tomorrow'
all other exams up this week will be shown with there week day.
above script is the begin part which devine date into arrays.
I hope someone can explain me what is happening and change it to code which i can use for my database.
Thanks in advance
Andres