<!DOCTYPE html> <html> <head> <title>List Trip</title> </head> <?php session_start(); $triptype = $_POST['round']; //1st loop if (($triptype=="one_trip")&&(@$_SESSION['username'])){ /* one way variable*/ $dep = $_POST['dpt_from']; $arive = $_POST['arive_to']; $day = $_POST['day_dep']; $month = $_POST['month_dep']; $year =$_POST['year_dep']; $time = $_POST['time_dep']; $adult = $_POST['no_of_pax_adult']; $child = $_POST['no_of_pax_child']; $date = "$year-$month-$day"; /*connect to database*/ $connectSQL = mysql_connect("localhost","root",""); if (!$connectSQL) die("Database Not Found".mysql_error()); $connectSelectdb = mysql_select_db("bobdatabse"); if (!$connectSelectdb) die("Error connect to database".mysql_error()); else{ $query = "SELECT * FROM trip_info WHERE date='$date' AND time='$time' AND depart='$dep' AND arive='$arive'"; $result = mysql_query($query); if(!$result) die("invalid query!".mysql_error()); else echo "<form name=listtrip method=post action=Reservation.php>"; echo "Go <b>$dep</b> to <b>$arive</b><br>"; echo "<table border=1px>"; echo "<tr><td>Date</td><td>Time</td><td>Departure</td><td>Arive</td><td>Price Adult</td><td>Price Child</td><td></td></tr>"; while($row=mysql_fetch_array($result, MYSQL_BOTH)) { echo "<tr><td>".$row['date']."</td><td>".$row['time']."</td><td>".$row['depart']."</td><td>".$row['arive']."</td><td>".$row['adult']." x ".$adult."=".$row['adult'] * $adult."</td><td>".$row['child']." x ".$child."=".$row['child'] * $child."</td><td><input type=submit value=Booking></td></tr>"; echo "<input type=hidden name=dep_from value='$dep'>"; echo "<input type=hidden name=arive_to value='$arive'>"; echo "<input type=hidden name=day_dep value='$day'>"; echo "<input type=hidden name=month_dep value='$month'>"; echo "<input type=hidden name=year_dep value='$year'>"; echo "<input type=hidden name=time_dep value='$time'>"; echo "<input type=hidden name=pax_adulta value='$adult'>"; echo "<input type=hidden name=pax_childb value='$child'>"; echo "<input type=hidden name=priceAdulta value=".$row['adult'].">"; echo "<input type=hidden name=priceChildb value=".$row['child'].">"; echo "<input type=hidden name=triptype value='$triptype'>"; } echo "</table>"; echo "</form>"; } } //2nd loops elseif (($triptype!="one_trip") && (@$_SESSION['username'])){ /*return variable*/ $depre = $_POST['dpt_from']; $arivere = $_POST['arive_to']; $dayre = $_POST['day_re']; $monthre = $_POST['month_re']; $yearre = $_POST['year_re']; $timere = $_POST['time_re']; $adultre = $_POST['no_of_pax_adult']; $childre = $_POST['no_of_pax_child']; $datere = "$yearre-$monthre-$dayre"; $day = $_POST['day_dep']; $month = $_POST['month_dep']; $year =$_POST['year_dep']; $time = $_POST['time_dep']; $date = "$year-$month-$day"; $triptype = $_POST['round']; $connectSQL = mysql_connect("localhost","root",""); if (!$connectSQL) die("Database Not Found".mysql_error()); $connectSelectdb = mysql_select_db("bobdatabse"); if (!$connectSelectdb) die("Error connect to database".mysql_error()); else $queryre = "SELECT * FROM round_trip_info WHERE date_frm ='$date' AND time_to='$time' AND date_re='$datere' AND time_re='$timere' AND depart_re='$depre' AND arive_re='$arivere'"; $resultre = mysql_query($queryre); if(!$queryre) die("invalid query!".mysql_error()); else echo "<form name=listtrip method=post action=Reservation.php>"; echo "Go <b>$depre</b> to <b>$arivere</b><br>"; echo "Return <b>$arivere</b> to <b>$depre</b></br>"; echo "<table border=1>"; echo "<tr><td>Trip ID</td><td>Date</td><td>Time</td><td>Departure</td><td>Arive</td><td>Date(Return)</td><td>Time(Return)</td><td>Departure(Return)</td><td>Arive(Return)</td><td>Price Adult</td><td>Price Child</td><td></td></tr>"; while($rows= mysql_fetch_array($resultre,MYSQL_BOTH)) { echo "<tr><td>".$rows['trip_id']."</td><td>".$rows['date_frm']."</td><td>".$rows['time_to']."</td><td>".$rows['depart_re']."</td><td>".$rows['arive_re']."</td><td>".$rows['date_re']."</td><td>".$rows['time_re']."</td><td>".$rows['depart_re']."</td><td>".$rows['arive_re']."</td><td>".$rows['adult_re']."</td><td>".$rows['child_re']."</td><td><input type=submit value=Booking></td></tr>"; echo "<input type=hidden name=dep_from value=".$rows['depart_re'].">"; echo "<input type=hidden name=arive_to value=".$rows['arive_re'].">"; echo "<input type=hidden name=dep_re value=".$rows['depart_re'].">"; echo "<input type=hidden name=arive_re value=".$rows['arive_re'].">"; echo "<input type=hidden name=date_go value=".$rows['date_frm'].">"; echo "<input type=hidden name=time_go value=".$rows['time_to'].">"; echo "<input type=hidden name=date_re value=".$rows['date_re'].">"; echo "<input type=hidden name=time_re value=".$rows['time_re'].">"; echo "<input type=hidden name=pax_adult value='$adultre'>"; echo "<input type=hidden name=pax_child value='$childre'>"; echo "<input type=hidden name=priceAdult value=".$rows['adult_re'].">"; echo "<input type=hidden name=priceChild value=".$rows['child_re'].">"; echo "<input type=hidden name=triptype value='$triptype'>"; } echo "</table>"; echo "</form>"; } else{ echo "No session exist or session is expired. Please login again <a href=Login.php>Login</a>. If you not a member <a href=Register.html>Register Here</a>."; } ?> </body> </html>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)