Jump to content

Listing schedules


orobouros

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

Link to comment
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.

Link to comment
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>";
?>

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...