orobouros Posted January 24, 2018 Report Share Posted January 24, 2018 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 Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted January 25, 2018 Moderators Report Share Posted January 25, 2018 Are you running the above pasted code within your phpVMS website? Where have you placed it? Quote Link to comment Share on other sites More sharing options...
orobouros Posted January 25, 2018 Author Report Share Posted January 25, 2018 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. Quote Link to comment Share on other sites More sharing options...
RuiMiguel Posted January 26, 2018 Report Share Posted January 26, 2018 hello see this Quote Link to comment Share on other sites More sharing options...
orobouros Posted January 26, 2018 Author Report Share Posted January 26, 2018 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>"; ?> 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.