Personal Catalogue: PHP & MySQL — Chapter 6, Exercise 1 ==================================================== TASK Build the full search.php from this chapter against your real database. Search for "Tolkien" with the type dropdown left on "All types" and confirm "The Hobbit" appears in the results even though "Tolkien" never appears in its own title. SOLUTION With search.php built using the combined query from the chapter (title LIKE :query OR creator LIKE :query, with the optional type/tag filters both left inactive since "All types" = 0 and "Any tag" = 0), visit: search.php?q=Tolkien&type=0&tag=0 The PHP builds this SQL and parameter set: SELECT items.* FROM items WHERE (items.title LIKE :query OR items.creator LIKE :query) ORDER BY items.title params: ['query' => '%Tolkien%'] Since $typeFilter and $tagFilter are both 0, neither the "AND items.item_type_id = :type_id" clause nor the tag JOIN is added to the query at all. Confirm at the mysql> prompt directly, to check the same result the PHP page should be showing: SELECT title, creator FROM items WHERE title LIKE '%Tolkien%' OR creator LIKE '%Tolkien%'; Expected output: +-------------+------------------+ | title | creator | +-------------+------------------+ | The Hobbit | J.R.R. Tolkien | +-------------+------------------+ The Hobbit is returned because "Tolkien" matches the creator column via the OR condition, even though the title column alone ("The Hobbit") contains no match at all. WHY THIS WORKS AS AN ANSWER ---------------------------- It confirms the specific behavior the OR condition exists to produce — finding a real, correct match via creator when title alone wouldn't — and cross-checks the PHP page's own result against a direct SQL query, rather than only trusting what appeared on screen.