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>";
}
}
}
?>
86
13
Other php-forum
Extra fields in main body and php required.
I'm new to PHP so please be gentle. I have a little php script below that works well.
The &quo
pagination - need help on passing of search query.
Hi, i have been trying for days but couldn't get this sorted out. Would like some professional help
need help modifying script
Hi guys,
I'm fairly new to php and am having a bit of trouble modifying a script.
This
Am i doing this wrong?
Im pulling from an Oracle database some info... one of which is a field count_pnums which is a NUMBE
PHP not creating file.
Its supposed to create a .ini file in the /scriptfiles/users/ with the name they entered into the fi
Variable passed to each() is not an array or object
Hi,
This is a email a friend type of form, and it isn't working anymore.
<?
socket makes browser hang...
I have a socket server, and I am having a problem at the moment...
A browser sends a http hea
Populate drop down list from table??
Lets say for arguments sake that i have a table which contains the numbers 1 to 10.
How can i get
1,000 select boxes with 100 options?!
I have 1 drop down select box with 1,000 options.
In some case, there will be 100+ of the
Wierd if else problem
Hi guys,
this probably aint wierd for you, but it seems like php is playin up to me. may b i