PHP Search Issue
Posted on
16th Feb 2014 07:03 pm by
admin
Hi, I am using the following code to search and return flights from a database. The user searches by inputting a DepID and an ArrID and I want to display only flights that match both DepID and ArrID. However at the moment I am get results only from DepID.. Im sure its something simple but any help appreciated.
Code: <?php
if(isset($_POST['submit'])){
if(isset($_GET['go'])){
if(preg_match("/^[ a-zA-Z]+/", $_POST['DepID'], $_POST['ArrID'])){
$DepID=$_POST['DepID'];
$ArrID=$_POST['ArrID'];
//connect to the database
$db=mysql_connect ("localhost", "HIDDEN", "HIDDEN") or die ('I cannot connect to the database because: ' . mysql_error());
//-select the database to use
$mydb=mysql_select_db("HIDDEN");
//-query the database table
$sql="SELECT FlightNo, DepID, DepTime, ArrID, ArrTime, Equip FROM routes WHERE DepID LIKE '%" . $DepID . "%' OR ArrID LIKE '%" . $ArrID ."%'";
//-run the query against the mysql query function
$result=mysql_query($sql);
//-create while loop and loop through result set
while($row=mysql_fetch_array($result)){
$FlightNo=$row['FlightNo'];
$DepID=$row['DepID'];
$DepTime=$row['DepTime'];
$ArrID=$row['ArrID'];
$ArrTime=$row['ArrTime'];
$Equip=$row['Equip'];
//-display the result of the array
echo "<ul>n";
echo "<li>" .$FlightNo . " " . $DepID . " " . $DepTime . " " . $ArrID . " " . $ArrTime . " " . $Equip . "</a></li>n";
echo "</ul>";
}
}
else{
echo "<p>Please enter a search query</p>";
}
}
}
?>
No comments posted yet
Your Answer:
Login to answer
86
13
Other forums
Lack of simpleXML Documentation
What is up with this.
Look at: http://www.php.net/manual/en/function.simplexml-load-file.php<
How to refresh a parent page from a modal popup
Hi,I have a modal popup in which I need to upload a file and store in the database should give a mes
filesize problem
i use ubuntu 9.10 and i have mountet a folder from an windows
/mount/FOLDER
/mount/FOLDER/
unexpected T_STRING
error log "[Sat Jan 09 18:27:58 2010] [error] [client 127.0.0.1] PHP Parse error: syntax error
Running a cron job through PHP/Apache?!
Hello all,
I have a PHP script which makes a cron file from user input. When i try to run the cro
PHP5 - AJAX help
I've been following the tutorial on w2schools (http://www.w3schools.com/php/php_ajax_database.asp) a
Add_Months not Easy to Understand
Oracle is number 1, very fast and very easy. But....
OK, I think but have a problem, only 1 pro
Inserting a variable in a link
I have this code that I want to insert for my own variable but I have no idea how. This is what I wa
fire away
i launched about 4 months ago as a lagit co. i have 2 paying clients, 1probono, 1 side progect, and
Need help in Generating Combinations
Need help generating all possible combination of names in an array
Lets say i have the follow