Listing schedules

Hi,

I want to list schedules by code, as it is in my sql request ($requete). This code is working, but i think it’s not the best way to connect to database. Does another way exist to connect to database safely without writing directly username, host, password and dbname ?

 

\<table class="myTable"\> \<!-- entête du tableau --\> \<thead\> \<tr\> \<th\>#ligne\</th\> \<th\>Dép. ICAO\</th\> \<th\>Arr. ICAO\</th\> \<th\>Appareil\</th\> \<th\>Distance\</th\> \<th\>Prix billet\</th\> \<th\>Opérations\</th\> \</tr\> \</thead\> \<?php $conn = mysqli\_connect('host', 'username', 'password', 'dbname'); $requete = "SELECT p.id, p.code, p.flightnum, p.depicao, p.arricao, fullname, p.distance, p.price FROM phpvms\_schedules p INNER JOIN phpvms\_aircraft a ON p.aircraft=a.id WHERE code='XXX'"; $res = $conn-\>query($requete); while ($element = mysqli\_fetch\_array($res)) { echo '\<tbody\>'; echo '\<tr\>'; echo '\<td\>'.$element['code'].' - '.$element['flightnum'].'\</td\> \<td\>'.$element['depicao'].'\</td\> \<td\>'.$element['arricao'].'\</td\> \<td\>'.$element['fullname'].'\</td\> \<td\>'.ceil($element['distance']).' nm\</td\> \<td\>'.$element['price'].' €\</td\> \<td\>\<a href="'.SITE\_URL.'/index.php/schedules/brief/'.$element['id'].'"\>Briefing\</td\>'; echo "\</tr\>"; } echo "\</tbody\>"; echo "\</table\>"; ?\>

Thanks for helping me,

Best regards

Are you running the above pasted code within your phpVMS website? Where have you placed it?

First I’ve made a folder in core/modules folder with a file containing a class wich extends codonModule. Then in core/templates folder, i’ve written the code above in a file called by the file in core/module folder. I want an automatisation of differents lists of schedules sorted by company code, on differents pages.

hello

see this

//forum.phpvms.net/applications/core/interface/index.html

 

i’ve made this, it works for me :

\<table class="Table"\> \<!-- entête du tableau --\> \<thead\> \<tr\> \<th\>Division - #ligne\</th\> \<th\>Dép. ICAO\</th\> \<th\>Arr. ICAO\</th\> \<th\>Appareil\</th\> \<th\>Distance\</th\> \<th\>Prix billet\</th\> \<th\>Opérations\</th\> \</tr\> \</thead\> \<?php $params = array( 's.code' =\> array ('xxx') ); $schedules = SchedulesData::findSchedules($params); foreach($schedules as $sched){ echo '\<tbody\>'; echo '\<tr\>'; echo '\<td\>'.$sched-\>code.' - '.$sched-\>flightnum.'\</td\> \<td\>'.$sched-\>depicao.'\</td\> \<td\>'.$sched-\>arricao.'\</td\> \<td\>'.$sched-\>aircraft.'\</td\> \<td\>'.ceil($sched-\>distance).' nm\</td\> \<td\>'.$sched-\>price.' €\</td\> \<td\>\<a href="'.SITE\_URL.'/index.php/schedules/brief/'.$sched-\>id.'"\>Briefing\</td\>'; echo "\</tr\>"; } echo "\</tbody\>"; echo "\</table\>"; ?\>