how to make a PHP search bar?
I'm making a market website and I want to know how I would make a search page.
I just need a page of divs that contain an image a button and text but how do I call images and buttons from a database with PHP? I've made a search bar that can search for and print text but how do I print HTML from a database?
- Robert JLv 71 month ago
The PHP page "prints out" the html the web browser will interpret.
You create that as needed to suit the page format and insert data read from the database as appropriate.
For variable size data (eg. an unknown number of results), use a loop that repeats the same format html block and increments through the results each time around.
If there is more than a reasonable page of data, you can set limits in the SQL request to the database to only get certain results (eg. 11 to 20 for the second page, if you had ten items per page), and pass the page number back to the PHP as a GET parameter with the "next page" button.