sql搜索使用就像不工作

i have an search box on website but whenever we search, it doesn't give any output.

I want to search for page title from database. But don't know what is wrong.

<div id="siteSearch">
    <h3>Site Search</h3>
    <?php
    if (isset($_POST['search'])) {
        $search = $_POST['search'];
        $query  = "SELECT * FROM pages WHERE ptitle LIKE '%$search%'";
        $result = mysql_query($query) or die(mysql_error());
        $count = mysql_num_rows($result);
        if ($count > 0) {
            while ($fetch = mysql_fetch_array($result)) {
                echo $fetch['ptitle'];
            }
        }
    } else {
        echo "No result found!";
    }
    ?>
</div>

You are using the semicolon after the while loop:

while($fetch = mysql_fetch_array($result));

Please remove the semicolon in this line.

You have a misplaced closing bracket. The one above else should be 5 lines below. As it currently stands, the else clause relates to if (isset($_POST['search'])).