Tato123 Posted February 24, 2014 Report Share Posted February 24, 2014 Hello Guys, I have a question to ask yourself. I have these schedules Flight number TOU001 TOU002 SOG001 SOG002 SOG003 SOG004 SOG005 I need to extract from the schedule with a query flights between flighnumber SOG001 and SOG003 I try with that query: <?php $query="SELECT * FROM phpvms_schedules WHERE flightnum BETWEEN 'SOG00001' And 'SOG00005'"; $list=DB::get_results($query); foreach ( $list as $ist) ?> With this query i show only a result. Can you tell me how to see all flighnumber between SOG0001 and SOG0005? Quote Link to comment Share on other sites More sharing options...
Members Vangelis Posted February 24, 2014 Members Report Share Posted February 24, 2014 Where flightnum => 001 and flightnum <= 003 Quote Link to comment Share on other sites More sharing options...
Tato123 Posted February 24, 2014 Author Report Share Posted February 24, 2014 Hi Vangeis, I try but don't work WHERE flightnum => 'SOG00001' and flightnum <= 'SOG00003' "; or WHERE flightnum => 00001 and flightnum <= 00003 "; in no way works <table width="750" class="tablevar" id="tabledlist"> <tr> <td>Volo N</td> <td>Dep.Air</td> <td>Arr.Air</td> <td>Dep.Time</td> <td>Arr.Time</td> <td>Aereo</td> <td>Dist</td> <td>Day</td> <td>Route</td> <td>Note</td> <td>Options</td> </tr> <?php $query="SELECT * FROM phpvms_schedules WHERE flightnum => 00001 and flightnum <= 00003 "; $list=DB::get_results($query); foreach ( $list as $ist) ?> <th><?php echo $ist->flightnum ?></th> <th><?php echo $ist->depicao ?></th> <th><?php echo $ist->arricao ?></th> <th><?php echo $ist->deptime ?></th> <th><?php echo $ist->arrtime ?></th> <th><?php echo $ist->aircraft ?></th> <th><?php echo $ist->distance ?></th> <th><?php echo Util::GetDaysCompact($ist->daysofweek); ?> <th><?php echo $ist->route_details ?></th> <th><?php echo $ist->notes ?></th> <th nowrap> <a href="<?php echo url('/schedules/details/'.$ist->id);?>">View Details</a><br /> <a href="<?php echo url('/schedules/brief/'.$ist->id);?>">Pilot Brief</a><br /> <?php # Don't allow overlapping bids and a bid exists if(Config::Get('DISABLE_SCHED_ON_BID') == true && $ist->bidid != 0) { ?> <a id="<?php echo $ist->id; ?>" class="addbid" href="<?php echo actionurl('/schedules/addbid');?>">Add to Bid</a> <?php } else { if(Auth::LoggedIn()) { ?> <a id="<?php echo $ist->id; ?>" class="addbid" href="<?php echo url('/schedules/addbid');?>">Add to Bid</a> <?php } } ?> </th> </table> <br /> Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted February 24, 2014 Moderators Report Share Posted February 24, 2014 Use WHERE flightnum >= '0001' and flightnum <= '0003' "; And check the 0 you have on your flight numbers... Quote Link to comment Share on other sites More sharing options...
Tato123 Posted February 24, 2014 Author Report Share Posted February 24, 2014 I check the 0, are 0000 (4) Warning: Invalid argument supplied for foreach() in/web/htdocs/www.virtualiroma.it/home/newvar/core/templates/tour/tour_index_sog.tpl on line 38 http://www.virtualiroma.it/newvar/index.php/Tour/get_tours_sog? Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted February 24, 2014 Moderators Report Share Posted February 24, 2014 Can you paste here the code you are using? Quote Link to comment Share on other sites More sharing options...
Tato123 Posted February 24, 2014 Author Report Share Posted February 24, 2014 <h3>Addestramento / Trasferimento</h3> <p>Con questa attivita' il pilota effettua: <br /> <br /> Addestramento nelle aree previste o da portaerei per carrier qualification (VOAT) <br /> <br /> Il trasferimento da un aeroporto militare ad un'altro, da portaerei a aereoporto militare e viceversa(VOAT O IOAT). <br /> <br /> AEREI: F-14, F-15, F-16, F-18, EUROFIGHTER, AV-8B (HARRIER), TORNADO, GRUMMAN A6 INTRUDER, AIRBUS A319, ATR 72, P180. <br /> <br /> ELI: A109, B212, B412, CH47, SH3D, MH53, SH60, EH101. <br /> </p> <br /> <table width="750" class="tablevar" id="tabledlist"> <tr> <td>Volo N</td> <td>Dep.Air</td> <td>Arr.Air</td> <td>Dep.Time</td> <td>Arr.Time</td> <td>Aereo</td> <td>Dist</td> <td>Day</td> <td>Route</td> <td>Note</td> <td>Options</td> </tr> <?php $query="SELECT * FROM phpvms_schedules WHERE flightnum >= '00001' and flightnum <= '00003' "; $list=DB::get_results($query); foreach ($list as $ist) ?> <th><?php echo $ist->flightnum ?></th> <th><?php echo $ist->depicao ?></th> <th><?php echo $ist->arricao ?></th> <th><?php echo $ist->deptime ?></th> <th><?php echo $ist->arrtime ?></th> <th><?php echo $ist->aircraft ?></th> <th><?php echo $ist->distance ?></th> <th><?php echo Util::GetDaysCompact($ist->daysofweek); ?> <th><?php echo $ist->route_details ?></th> <th><?php echo $ist->notes ?></th> <th nowrap> <a href="<?php echo url('/schedules/details/'.$ist->id);?>">View Details</a><br /> <a href="<?php echo url('/schedules/brief/'.$ist->id);?>">Pilot Brief</a><br /> <?php # Don't allow overlapping bids and a bid exists if(Config::Get('DISABLE_SCHED_ON_BID') == true && $ist->bidid != 0) { ?> <a id="<?php echo $ist->id; ?>" class="addbid" href="<?php echo actionurl('/schedules/addbid');?>">Add to Bid</a> <?php } else { if(Auth::LoggedIn()) { ?> <a id="<?php echo $ist->id; ?>" class="addbid" href="<?php echo url('/schedules/addbid');?>">Add to Bid</a> <?php } } ?> </th> </table> <br /> Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted February 24, 2014 Moderators Report Share Posted February 24, 2014 I would suggest you ti create a TourData.class.php file on you common folder and include the select function there. Personally, I do know why it does not work and i do not suggest including database functions on your .tpl files. Quote Link to comment Share on other sites More sharing options...
Tato123 Posted February 25, 2014 Author Report Share Posted February 25, 2014 I have create a TourData.class.php file in my common folder and i have include the select function but don't work. I cry Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted February 25, 2014 Moderators Report Share Posted February 25, 2014 Can you paste the code you are using on your files? Quote Link to comment Share on other sites More sharing options...
Tato123 Posted February 25, 2014 Author Report Share Posted February 25, 2014 The Function in my TOUR Module: public function get_schedules_sog() { $this->set('schedules', TourData::get_sog_schedules()); $this->show('tour/tour_schedules_sog.tpl'); } The Query in my TourData.Class public function get_sog_schedules() { $query = "SELECT * FROM ".TABLE_PREFIX."schedules WHERE flightnum >= '00001' and flightnum <= '00003' "; return DB::get_results($query); } my tour_schedules_sog.tpl <h3>Addestramento / Trasferimento</h3> <table width="750" class="tablevar"> <tr> <td>Volo N</td> <td>Dep.Air</td> <td>Arr.Air</td> <td>Dep.Time</td> <td>Arr.Time</td> <td>Aereo</td> <td>Dist</td> <td>Route</td> </tr> <?php $schedules=DB::get_results($query); foreach ($schedules as $ist) ?> <th><?php echo $ist->flightnum ?></th> <th><?php echo $ist->depicao ?></th> <th><?php echo $ist->arricao ?></th> <th><?php echo $ist->deptime ?></th> <th><?php echo $ist->arrtime ?></th> <th><?php echo $ist->aircraft ?></th> <th><?php echo $ist->distance ?></th> <th><?php echo $ist->route_details ?></th> </table> with: WHERE flightnum >= '00001' and flightnum <= '00003' "; i have an error in foreach, if i change in the query: WHERE flightnum >= '00001' and flightnum <= '00003' "; in WHERE flightnum >= 'SOG00001' and flightnum <= 'SOG00003' "; I see all 1 record, the SOG00003 Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted February 25, 2014 Moderators Report Share Posted February 25, 2014 Try WHERE flightnum > '00000' and flightnum < '00004' "; Â Just to test Quote Link to comment Share on other sites More sharing options...
Tato123 Posted February 25, 2014 Author Report Share Posted February 25, 2014 Nothing, Warning: Invalid argument supplied for foreach() in /web/htdocs/www.virtualiroma.it/home/newvar/core/templates/tour/tour_schedules_sog.tpl on line 16 Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted February 25, 2014 Moderators Report Share Posted February 25, 2014 First of all remove this from the tour_schedules_sog.tpl file (line 14): $schedules=DB::get_results($query); Check if it works now... Quote Link to comment Share on other sites More sharing options...
Tato123 Posted February 25, 2014 Author Report Share Posted February 25, 2014 nothing is the same Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted February 25, 2014 Moderators Report Share Posted February 25, 2014 Please upload and send me the files in order to check them. Send the to info(at)php-mods(dot)eu . I will check it and i will let you know... Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted February 25, 2014 Moderators Report Share Posted February 25, 2014 Problem solved. TourData.class.php file should be: public function get_sog_schedules() { $sql = "SELECT * FROM ".TABLE_PREFIX."schedules WHERE flightnum>='SOG00001' AND flightnum<='SOG00015' ORDER BY flightnum"; return DB::get_results($sql); } Quote Link to comment Share on other sites More sharing options...
Tato123 Posted February 28, 2014 Author Report Share Posted February 28, 2014 Thanks Very much !!!!!! 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.