PHP MySQL数据库多重过滤

So I have a table with a whole load of properties and have displayed them on a webpage. As we have a wide range I developed a filtration system. However when used you can only select one tag, but we want to devise it in a way so that you can select one tag and then another. My current code is as follows.

<h3>Advanced Search:</h3>

    <table>
<tr>
    <td colspan="2" style="vertical-align: top; width:50%; !important;">
          <h3>Location</h3>
          <div>
            <a href="webpropertyloc.php?loc=Alsancak" data-ajax="false" class="ui-btn">Alsancak</a>
            <a href="webpropertyloc.php?loc=Karsiyaka" data-ajax="false" class="ui-btn">Karsiyaka</a>
            <a href="webpropertyloc.php?loc=Lapta" data-ajax="false" class="ui-btn">Lapta</a>
            <a href="webpropertyloc.php?loc=Kayalar" data-ajax="false" class="ui-btn">Kayalar</a>
            <a href="webpropertyloc.php?loc=Sadrazamkoy" data-ajax="false" class="ui-btn">Sadrazamkoy</a>
            <a href="webpropertyloc.php?loc=Camlibel" data-ajax="false" class="ui-btn">Cambeli</a>
            <a href="webpropertyloc.php?loc=Baspinar" data-ajax="false" class="ui-btn">Baspinar</a>
            <!--<a href="property.php?loc=" data-ajax="false" class="ui-btn"></a>
            <a href="property.php?loc=" data-ajax="false" class="ui-btn"></a>
            <a href="property.php?loc=" data-ajax="false" class="ui-btn"></a>-->
          </div>
          </td>


    <td style="vertical-align: top; width:25%;">      
          <h3>Number of Bedrooms</h3>
          <div>
            <a href="webpropertybed.php?bed=1" data-ajax="false" class="ui-btn">1</a>
            <a href="webpropertybed.php?bed=2" data-ajax="false" class="ui-btn">2</a>
            <a href="webpropertybed.php?bed=3" data-ajax="false" class="ui-btn">3</a>
            <a href="webpropertybed.php?bed=4" data-ajax="false" class="ui-btn">4</a>
          </div>
    </td>

And it goes on with another few options the code then on the page is as follows:

    <h1>Properties</h1>

    <?php
    $loc = $_GET["loc"];
    $con = mysql_connect("localhost","Username","Password");
    mysql_selectdb("db",$con);
    $sql = "SELECT * FROM Properties WHERE Location='$loc' ORDER BY  `Properties`.`Price` ASC";
    $mydata = mysql_query($sql,$con);

    echo "<h4>Location:" . $loc . "</h4><br>";

    while($record = mysql_fetch_array($mydata)){
        echo  "<div id=\"property\">" . "<img src=\"images/" . $record['MainPic'] . "\" id=\"propimg\" align=\"left\">" . "<div id=\"text\" style=\"text-align: center; margin-right:20px;\"><h2>" . $record['Title'] . "</h2>" . $record['Ref'] . "<br/>" . "&pound;" . $record['Price'] . "<br/>" . $record['Location'] . "<br/>" . "<a href=\"property_view.php?id=" . $record['ID'] . "\" data-ajax=\"false\" class=\"ui-btn\" id=\"button\">Details</a></div>" . "<img src=\"images/bottom-line.png\" id=\"bottomline\"></div>" . "</div>" ;

    }

    mysql_close($con);
    ?>

Any help would be greatly received. Thanks in advance!

I would suggest using the same page for displaying the results, whether the filter applies to the location or the number of bedrooms. You can always use WHERE (1 = 1) in your SQL so that you can append AND (Location='$loc') or AND (Beds='$bed'), though it would be preferable to use parameters.

Once you have that set up, you can modify your links. Let's say your destination page is webproperty.php. Store that URL in a variable $urlDest.

When you generate your links for filtering by location, add any variables in $_GET that aren't loc to the end of $urlDest, getting something like webproperty.php?bed=2. As you iterate through your locations, append the loc variable to $urlDest, like "<a href=\"$urlDest&amp;loc=$loc\">".

Similarly, when you generate your links for filtering by bedroom count, add any variables in $_GET that aren't bed to the end of $urlDest, getting something like webproperty.php?loc=Alsancak. As you iterate through your bedroom counts, append the bed variable to $urlDest, like "<a href=\"$urlDest&amp;bed=$bed\">".