Jump to content

[SOLVED] Searching database with drop down lists


pure_skill_2000

Recommended Posts

Hi

 

Im having a dumb problem with the code for a search, I want to allow the user to search with different fields, with the options populated from the choices in the database.

 

For example LFA 3 in 2004

 

but I cannt get it to work :( Ive never tried this before its probably simple but im lost!

 

<?php
//// filename = search.php
<form name="search" method="post" action="result.php">
<select name="metode" size="1">
<option value="Aircraft Type">Aircraft Type</option>
<option value="LFA">LFA</option>
</select>
<input type="text" name="search" size="25">
<input type="submit" value="Begin Searching!!">
</form>
?>

//// filename = result.php
<?php
$hostname = 
$username = 
$password = 
$usertable = 
$dbName = 
MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect to database");
@mysql_select_db( "$dbName") or die( "Unable to select database");
?>
<?
//error message (not found message)
$XX = "No Record Found";
$query = mysql_query("SELECT * FROM $usertable WHERE $metode LIKE '%$search%' LIMIT 0, 30 ");
while ($row = mysql_fetch_array($query))
{
$variable1=$row["Aircraft Type"];
$variable2=$row["LFA"];
$variable3=$row["Intensity"];
print ("this is for $variable1, and this print the variable2 end so on...");
}

//below this is the function for no record!!
if (!$variable1)
{
print ("$XX");
}
//end
?>

 

Ive tried to follow an online tutorial

I have a syntax "<" error on line 3 any suggestions?

 

<?php
//// filename = search.php
<form name="search" method="post" action="result.php">
<select name="metode" size="1">
<option value="Aircraft Type">Aircraft Type</option>
<option value="LFA">LFA</option>
</select>
<input type="text" name="search" size="25">
<input type="submit" value="Begin Searching!!">
</form>
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.