搜索sql数据并在php上显示

This is a repost but my previous one wouldn't let me edit. I'm trying to take details from a html/php page and allow at the user to "search" through the results page, however, when I enter a search term nothing is displayed on the search.php page.

HTML/PHP showing current details + searchbox:

<form method="post" action="search.php">
<input type="text" name="search" />
<input type="submit" name="submit" value="   Search   ">
</form>

<div id="leftdiv" style="width: 40%; float:left">
    <form id="form1" method="get">
    <table id="table">
        <th>Property ID</th>
        <th>Property Name</th>
            <?php   
            $result = mysql_query("SELECT * FROM Property");
            while ($row = mysql_fetch_array($result))
                {
                    $pID = $row['pID'];
                    $pLocation = $row['pLocation'];

                    echo "<tr data-row='$pID'><td>$pID</td>";
                    echo "<td>".$pID."</td>";
                    echo "<td>".$pLocation."</td>";
                }
            ?>
    </table>
    </form>
</div>

searchresults.php code:

$search=$_POST['search'];
$sql="SELECT * FROM Property
WHERE pLocation like 'search%'";

$result=mysql_query($sql) or die(mysql_error());


while ($row=mysql_fetch_array($result))
            {
            $pID = $row['pID'];
            $pLocation = $row['pLocation'];
            echo "<tr data-row='$pID'>";
            echo "<td>".$pID."</td>";
            echo "<td>".$pLocation."</td></tr>";
            }

Essentially all im trying to do is display all properties in database, then allow user to filter results based on location. If they type in London, only properties in London to be shown.

Ok try this: i've escaped the search, and added an else case if you get no results back:

$search= mysql_real_escape_string($_POST['search']);
$sql="SELECT * FROM Property
WHERE pLocation like '".$search."%'";

$result=mysql_query($sql) or die(mysql_error());

if (count($result)) {
    while ($row=mysql_fetch_array($result))
            {
            $pID = $row['pID'];
            $pLocation = $row['pLocation'];
            echo "<tr data-row='$pID'>";
            echo "<td>".$pID."</td>";
            echo "<td>".$pLocation."</td></tr>";
    }
} else {
    echo "<tr><td colspan='3'>No results found.</td></tr>";
}

Note: this is a followup to this question

Your query should be

$sql = "SELECT * FROM Property WHERE pLocation like '$search%'";

Note that is not a good way to do it - as earlier comments mention, you are using a deprecated database API, and you're making yourself vulnerable to SQL injections.

I wonder why you added javascript as the first tag, not much js here.