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'])){
Did you know?Explore Trending and Topic pages for more stories like this.
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 Like 13 Dislike
Previous forums Next forums
Other forums

Internal class functions don't seem to get executed.
Hi. Can someone please put me out of my misery on this. I don't write much PHP and this has me baffl

ClientScript.RegisterClientScriptBlock Issue
This is what I haveview plaincopy to clipboardprint?Protected Sub posrback_Click(ByVal sender As Obj

error reporting
hey everyone

I have a production server in which I want error reporting but only on some page

IIS on 2003 anon access disabled issue
I have an IIS server that belongs to a domain, and anonymous access is turned off for all my sites.

Convert Binary String to Decimal
Trying to Get:
Decimal: 305419896

Out of:
Binary String: xV4

whats wrong with my code please help!!!
this is the error


Warning: mysql_close(): supplied argument is not a valid MySQL-Link res

Pls help with PHP
Pls can anyone direct me on how to create a user account for a customer. For example i want know if

small inaccuracies
I have this code to convert fractional base 10 into base 2:

while($num > 0)

Help: calling function
Hi,
Is it possible to call a php function on page close?
If yes, could you explain how and whe

Got A Free Server :(
So I was given a free server

http://shopping.yahoo.com/p:Compaq%20ProLiant%201500%20Server:1

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash