Currently i can search in a box for a specific thing in my database but i can't search in my drop down menus which i need so it can help "find" it as well so it can narrow down the search.

my current code:

<?php
  $mysql_link = mysql_connect('localhost', 'root', '');
  if (!$mysql_link) {
    die('Not connected : ' . mysql_error());
  }

  // select DB DVD
  $db_selected = mysql_select_db('DVD', $mysql_link);
  if (!$db_selected) {
    die ('Can\'t use DVD database : ' . mysql_error());
  }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>DVD Search :)</title>
                </head>
                     <body>
        <form name="dvdlist" action="result.php" method="GET">
        Find a specific DVD: <input type="text" name="q"/>
            

        <b>Rating</b>
                <select name="a">
                <option value="">Pick a rating...</option>
                <option value="G">G</option>
                <option value="PG">PG</option>
                <option value="PG-13">PG-13</option>
                <option value="NR">NR</option>
                <option value="UNK">UNK</option>
                <option value="VAR">VAR</option>
                <option value="R">R</option>

        </select>

        <b>Genre</b>

                <select name="b">
                <option value="">Pick a genre...</option>
                <option value="Action/Adventure">Action / Adventure</option>
                <option value="Action/Comedy">Action / Comedy</option>
                <option value="Adventure">Adventure</option>
                <option value="Animation">Animation</option>
                <option value="Anime">Anime</option>
                <option value="Ballet">Ballet</option>
                <option value="Comedy">Comedy</option>
                <option value="Comedy/Drama">Comedy / Drama</option>
                <option value="Documentary">Documentary</option>
                <option value="Drama">Drama</option>
                <option value="Family">Family</option>
                <option value="Fantasy">Fantasy</option>
                <option value="Foreign">Foreign</option>
                <option value="Horror">Horror</option>
                <option value="Late Night">Late Night</option>
                <option value="Music">Music</option>
                <option value="Musical">Musical</option>
                <option value="Mystery/Suspense">Mystery / Suspense</option>
                <option value="Opera">Opera</option>
                <option value="Other">Other</option>
                <option value="Satire">satire</option>
                <option value="SciFi">ScFi</option>
                <option value="Special Interest">Special Interest</option>
                <option value="Suspense/Thriller">Suspense / Thriller</option>
                <option value="Thriller">Thriller</option>
                <option value="Classics">TV Classics</option>
                <option value="VAR">VAR</option>
                <option value="War">War</option>
                <option value="Western">Western</option>

                <input type="submit" name="Submit" value="Search" />
            </select>
        </form>
    </body>
</html>
<?php

  // Get the search variable from URL

  $var = @$_GET['q'] ;
  $trimmed = trim($var); //trim whitespace from the stored variable

// rows to return
  $limit=2299;

// check for an empty string and display a message.
if ($trimmed == "")
  {
  echo "<p>Please enter a search...</p>";
  exit;
  }

// check for a search parameter
if (!isset($var))
  {
  echo "<p>We dont seem to have a search parameter!</p>";
  exit;
  }

//connect to your database ** EDIT REQUIRED HERE **
mysql_connect("localhost","root",""); //(host, username, password)

//specify database ** EDIT REQUIRED HERE **
mysql_select_db("dvd") or die("Unable to select database"); //select which database we're using

// Build SQL Query
$query = "SELECT * FROM dvd_list where Title like \"%$trimmed%\"
  order by Rating "; // EDIT HERE and specify your table and field names for the SQL query

 $numresults=mysql_query($query);
 $numrows=mysql_num_rows($numresults);

// If we have no results, offer a google search as an alternative

if ($numrows == 0)
  {
  echo "<h4>Results</h4>";
  echo "<p>Sorry, your search: &quot;" . $trimmed . "&quot; returned zero results</p>";
// google
 echo "<p><a href=\"http://www.google.com/search?q="
  . $trimmed . "\" target=\"_blank\" title=\"Look up
  " . $trimmed . " on Google\">Click here</a> to try the
  search on google</p>";
  }

// next determine if s has been passed to script, if not use 0
  if (empty($s)) {
  $s=0;
  }

// get results
  $query .= " limit $s,$limit";
  $result = mysql_query($query) or die("Couldn't execute query");

// display what the person searched for
echo "<p>You searched for: &quot;" . $var . "&quot;</p>";


// begin to show results set
echo "<h2>DVD(s) Found!</h2> <br /> <hr />";
$count = 1 + $s ;

// now you can display the results returned
  while ($row= mysql_fetch_array($result)) {
  $title = $row["Title"];
  $rating = $row ["Rating"];
  $genre = $row ["Genre"];
  $year = $row ["Year"];

  echo "  <b>$count.)</b>&nbsp;$title <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Rating:</b> $rating <br />
  &nbsp;&nbsp;&nbsp;&nbsp;<b> Genre: </b>$genre <br/>
  &nbsp;&nbsp;&nbsp;&nbsp;<b> Year: </b>$year <br/> <hr />" ;
 
  $count++ ;
  }

$currPage = (($s/$limit) + 1);

//break before paging
  echo "<br />";
  // next we need to do the links to other results

$a = $s + ($limit) ;
  if ($a > $numrows) { $a = $numrows ; }
  $b = $s + 1 ;
  echo "<p>Showing results $b to $a of $numrows</p>";
  echo "<hr />"
?>
<html>
    <body>
        <a href="index.php">Back</a>
    </body>
</html>

bump

commented: 24/7 service just for you. Do not create bumps! -3
Member Avatar for diafol

Don't know if it'll make a difference:

<option value="Western">Western</option>
  <input type="submit" name="Submit" value="Search" />
</select>

Should be

<option value="Western">Western</option>
 </select>
<input type="submit" name="Submit" value="Search" />

can you please tell me if any one search result come ! please sure

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.