Tato123 Posted April 28, 2014 Report Share Posted April 28, 2014 Hello, I'm trying to do a search for bands of time using the form Frontschedules. In the airport search.tpl I entered this search option: <tr> <td>Orario</td> <td> <select class="search" name="deptime"> <option value="">All</option> <option value="00:01|08:00">00.01/08.00</option> <option value="08:01|16:00">08.01/16.00</option> <option value="16:01|24:00">16.01/24.00</option> </select> </td> </tr> In the FrontSchedules.php: public function findflight() { $arricao = DB::escape($this->post->arricao); $depicao = DB::escape($this->post->depicao); $airline = DB::escape($this->post->airline); $aircraft = DB::escape($this->post->aircraft); $deptime = DB::escape ($this->post->deptime); if(!$airline) { $airline = '%'; } if(!$arricao) { $arricao = '%'; } if(!$depicao) { $depicao = '%'; } if($aircraft == !'') { $aircrafts = FrontSchedulesData::findaircraft($aircraft); foreach($aircrafts as $aircraft) { $route = FrontSchedulesData::findschedules($arricao, $depicao, $airline, $aircraft->id); if(!$route){$route=array();} if(!$routes){$routes=array();} $routes = array_merge($routes, $route); } } else { $routes = FrontSchedulesData::findschedule($arricao, $depicao, $airline, $deptime); } $this->set('allroutes', $routes); $this->show('schedule_results.tpl'); } and inFrontSchedulesData Class: public function findschedule($arricao, $depicao, $airline, $deptime) { $query = "SELECT phpvms_schedules.*, phpvms_aircraft.name AS aircraft, phpvms_aircraft.registration FROM phpvms_schedules, phpvms_aircraft WHERE phpvms_schedules.depicao LIKE '$depicao' AND phpvms_schedules.arricao LIKE '$arricao' AND phpvms_schedules.deptime LIKE '$deptime' AND phpvms_schedules.code LIKE '$airline' AND phpvms_aircraft.id LIKE phpvms_schedules.aircraft"; return DB::get_results($query); } How is possible changing the query for search the time from the option value? If i try with option valure ="8.25" i find all the flight at this time. I won't search the range. Thanks Quote Link to comment Share on other sites More sharing options...
Ephendi Posted May 22, 2014 Report Share Posted May 22, 2014 in search request page: date_default_timezone_set("UTC"); $casodletu= date("H:i:s", time()); <td>Select Departure time:</td> <td> <select class="search" name="deptime"> <?php {echo '<option value="'.$casodletu.' selected">Upcoming</option>';} {echo '<option value="">All</option>';} ?> </select> </td> in FrontSchedulesData class insert in function findschedule public function findschedule($arricao, $depicao, $airline, $deptime) { $query = "SELECT phpvms_schedules.*, phpvms_aircraft.name AS aircraft, phpvms_aircraft.registration FROM phpvms_schedules, phpvms_aircraft WHERE phpvms_schedules.depicao LIKE '$depicao' AND phpvms_schedules.arricao LIKE '$arricao' AND phpvms_schedules.code LIKE '$airline' AND phpvms_schedules.deptime > '$deptime' ..... this will show for you departure after current GMT time. Other (your modification of FrontSchedules.php is good). Quote Link to comment Share on other sites More sharing options...
Tato123 Posted May 23, 2014 Author Report Share Posted May 23, 2014 Thanks, work great ! I have only a problem ..the flight aren't order by deptime. Any suggestion ? Quote Link to comment Share on other sites More sharing options...
ln-asm Posted May 23, 2014 Report Share Posted May 23, 2014 Try: ORDER BY deptime ASC That should do the trick Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.