masnobi Posted April 4, 2013 Share Posted April 4, 2013 (edited) Hi all, I am working on a project where I am creating a travel agency website. At the moment I am trying to get my search engine to get the details and show the result into next page, but nothing is working. can anyone please help? thanks in advance. sorry for my messy code as I AM VERY NEW TO PHP Here are my codes for the form on index.php <form id="search" Name ="sEngine" Method ="POST" ACTION ="search.php" style="background-image:url(images/background.jpg)"> <h2>Search Flights</h2> <fieldset> <input type = "radio" name = "type" id = "return" value = "yes" checked = "checked" /> <label for = "return">Return</label> <input type = "radio" name = "type" id = "single" value = "no" /> <label for = "single">Single</label> </fieldset> <fieldset id="des"> <ul> <li> <label for="depAirport">Deperture airport</label> <input type="text" id="depAirport" name="depAirport" placeholder="Type destination airport" required autofocus> </li> <li> <label for="arrAirport">Arrival airport</label> <input type="text" id="arrAirport" name="arrAirport" placeholder="Type arrival airport" required> </li> <li> <label for="dDate">Departure date</label> <input type="date" id="dDate" name="dDate" required> </li> <li> <label for="rdate">Return date</label> <input type="date" id="rDate" name="rDate" required> </li> </ul> </fieldset> <fieldset> <label for="adult" style="margin-left:10px;">Adult</label> <input type="number" id="adult" name="adult" min="1" max="20"> <label for="child" style="margin-left:8px;">Child </label> <input type="number" id="child" name="child" min="0" max="10"> <label for="infants" style="margin-left:8px;">Infants </label> <input type="number" id="infants" name="infants" min="0" max="10"> </fieldset> <fieldset> <label for="clsType" style="margin-left:80px;">Class type</label> <select id = "myList" name="myList"> <option value = "1" selected="selected">Economy</option> <option value = "2">Premium Economy</option> <option value = "3">Business</option> <option value = "4">First</option> </select> </fieldset> <br/> <button type= "submit" onclick="myfunc()">Search Now!</button> </form> Here are my codes for search.php <?php mysql_connect("localhost", "root", "masnobi");mysql_select_db("airline_database"); ?> <?php function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } $name=mysql_real_escape_string($_POST['depAirport']); //This value has to be the same as in the HTML form file $email=mysql_real_escape_string($_POST['arrAirport']); //This value has to be the same as in the HTML form file $sql= "SELECT * from 'flight' WHERE (departure_airport ='$depAirport' , arrival_airport = '$arrAirport', departure_date ='$dDate')"; echo "<table id='box' border='1' cellpadding='2' summary='Table holds flight information'> <tr> <th>flight_id</th> <th>flight_no</th> <th>departure_airport</th> <th>arrival_airport</th> <th>departure_date</th> <th>arrival_date</th> <th>flight_price</th> <th>flight_duration</th> <th>flight_name</th> </tr>"; while ($row = mysql_fetch_array($result)) {echo "<tr>"; echo "<td>" . $row['flight_id'] . "</td>"; echo "<td>" . $row['flight_no'] . "</td>"; echo "<td>" . $row['departure_airport'] . "</td>"; echo "<td>" . $row['arrival_airport'] . "</td>"; echo "<td>" . $row['departure_date'] . "</td>"; echo "<td>" . $row['arrival_date'] . "</td>"; echo "<td>" . '£' . $row['flight_price'] . "</td>"; echo "<td>" . $row['flight_duration'] . "</td>"; echo "<td>" . $row['flight_name'] . "</td>"; echo "</tr>"; } ?> Edited April 4, 2013 by KevinM1 Code tags Quote Link to comment https://forums.phpfreaks.com/topic/276536-how-to-make-my-search-engine-work/ Share on other sites More sharing options...
TOA Posted April 4, 2013 Share Posted April 4, 2013 (edited) I didn't look too close, but your query should be failing due to the mal-formed WHERE statement. Try this: WHERE departure_airport ='$depAirport' AND arrival_airport = '$arrAirport' AND departure_date ='$dDate' Turn on error reporting, it would have caught that. Edited April 4, 2013 by TOA Quote Link to comment https://forums.phpfreaks.com/topic/276536-how-to-make-my-search-engine-work/#findComment-1422932 Share on other sites More sharing options...
KevinM1 Posted April 4, 2013 Share Posted April 4, 2013 In the future, please put any code you want to post in a code block. You can do this by pressing the <> button on the editor. Quote Link to comment https://forums.phpfreaks.com/topic/276536-how-to-make-my-search-engine-work/#findComment-1422934 Share on other sites More sharing options...
masnobi Posted April 4, 2013 Author Share Posted April 4, 2013 Hey guys, I fixed it. so no worries. thanks for help anyway Quote Link to comment https://forums.phpfreaks.com/topic/276536-how-to-make-my-search-engine-work/#findComment-1422952 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.