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

Link to comment
Share on other sites

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>
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.