if query passed in search box by selecting the category as fiction or whatever it may be, it should search in both title and author, if value got in title then no need to search in author, if not need to search in author,

    $search = $_POST['searchvalue']; //assume search value as xyz
    $name = $_POST['name'];// assume category as fiction

 $construct = "SELECT * FROM books WHERE category = $name  AND (title LIKE '%$search%' or author LIKE '%$search%')";
     $run = mysql_query($construct);
     $foundnum = mysql_num_rows($run);// I am getting error here

please anyone help me
database table is given below

Recommended Answers

It happens because the query returns FALSE instead of returning a result set, there is an error in your query, try to add the quotes around $name:

... category = '$name' ...

But you should really switch to prepared statements:

Jump to Post

All 2 Replies

Thank you very much it worked...

Be a part of the DaniWeb community

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