I am working on building a PHP based filter that will narrow down a search based on criteria specified by drop downs in the HTML file. In the MySQL file I have a column for a image_url, client, and service. When the search is complete I would like to display the image, client name, and services.
Currently I have the PHP setup to seach based on one specific set of criteria. I would like for it to take into account the extra set of perameters. How can I do this? Thanks in advance!
This is what I have so far.
HTML
<!DOCTYPE HTML>
<html>
 <head>
  <meta charset="UTF-8" />
  <title>Filter</title>
 </head>
<body>
 <br />
<form action="filter.php" method="post">
  Search by:
  <br />
Client:
<select name="client">
  <option value="any">- Any -</option>
  <option value="1">Test 1</option>
  <option value="2">Test 2</option>
  <option value="3">Test 3</option>
</select>
 Services: 
<select name="services">
  <option value="any">- Any -</option>
  <option value="1">Test 1</option>
  <option value="2">Test 2</option>
</select>
 <input type="submit" value="Submit" />
</form>
</body>
</html>
PHP
<?php
            // declare sting variable and set value to link to index.html
            // connect to database and select database 'directory'
            $con = mysql_connect("localhost","username","123456");
            if (!$con)
            {
                  die('Could not connect: ' . mysql_error());
            }
            mysql_select_db("filter", $con);
            $name = 'name';
            if (isset($_REQUEST['client']))
            {
                  $name = trim($_REQUEST['client']);
            } else {
                  echo "Sorry, no search criteria.";
                  exit;
            }
            // contains the string input by the user on the name.html page
            $query = "SELECT * FROM filter WHERE client LIKE '".mysql_real_escape_string($client)."%'";
            $result = mysql_query($query) or die( "Problem executing: ". $query . " " . mysql_error() );
            // if no results are returned from the query, give error message and exit
            if (mysql_num_rows($result) == 0) {
                  echo "Sorry, no matching results.";
                  exit;
            }
            while ($row = mysql_fetch_assoc($result)) {
                       echo "<img src="<?php echo $row["image_url"]; ?>"/> ;
                        echo "<b>Client: </b>";
                  echo $row["client"] ;
                  echo  " ";
                  echo "<b>Services: </b>";
                  echo $row["services"];
                  echo "<br>";
                  echo "<br>";
            }
            ?>
 
     
     
     
     
    