Jump to content
orobouros

Listing schedules

Recommended Posts

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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>";
?>

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×