57: How to create a search field with PHP and MySQLi | PHP tutorial | Learn PHP programming


How to create a search field with PHP and MySQLi – Learn PHP backend programming. In this video we will learn how to create a search feature using PHP from scratch.


First of all, thank you for all the support you have given me!

I am really glad to have such an awesome community on my channel. It motivates me to continue creating and uploading content! So thank you!

I am now using Patreon to share improved and updated lesson material, and for a small fee you can access all the material. I have worked hard, and done my best to help you understand what I teach.

I hope you will find it helpful 🙂

Material for this lesson:



  1. Hello bro I am unable to login to phpmyadmin to connect to MySQL and getting this error and I tried all the trouble shooting steps but still same issue, "Failed To Set Session Cookie. Maybe You Are Using HTTP Instead Of HTTPS To Access PhpMyAdmin."

  2. Dude… I'm here in 2020 and your tutorials are just the best, no doubt about it. You explain everything so good and I have NEVER failed with something when watching your tutorials. Are you a magician or something? haha 😀

    SHOUT OUT ALL THE WAY FROM SOUTH AFRICA!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  4. Thank you bro you're the best GEEK, I had a problem of search bar which was missing on my site and now you saved my a**!! Thank you so so much. If possible you would make for me two videos one showing how to add a download button with an embedded link from the database and another one showing how to make an auto_complete search-bar.

  5. Very Nice Tutorial! Super easy to follow thank you! Can you make a video how to search every table in a database? Like for example you have 5 tables (cars, users, maintenance, contact, price). Because I been trying to refactor your example code but it's fighting me and being a beginner I don't know enough about PHP to figure why I can't get it to work.

  6. do the SQL still work? Static analysis:

    3 errors were found during analysis.

    A comma or a closing bracket was expected. (near "nut" at position 38)

    Unexpected start. (near "256" at position 96)

    Unknown setting type. (near "NOT NULL" at position 101)


    CREATE TABLE article ( a_id int(11) nut null PRIMARY KEY AUTO_INCREMENT, a_title varchar(256) NOT NULL, a_text text not null, a_author varchar(256) NOT NULL, a_date datetime not null )

    MySQL said: Dokumentasjon

    #1064 – Something is wrong in your syntax near 'null PRIMARY KEY AUTO_INCREMENT,

    a_title varchar(256) NOT NULL,

    a_text' på line 2

  7. How do we turn the $row values into individual variables to make make html design and styling easier. So we can implement the results one at a time and apply individual styling?

  8. Daniel, I have a stupid question. Can I save in Article's text (a_text) html tags? For a better formatting on view page. Like <br>, <b>, <img>…..Is that okay and safe?

  9. Omg! This is one of the best videos I have ever seen?!!!
    The way you have explained the concepts is really awesome?
    Keep making such video.❤️from??

  10. Very nice things so beautifully explained. Before watching this video, I thought searching is the most puzzling part of the website but after that I'm just like this is a piece of piss..???

  11. At 24:20 in your tutorial video I get this error "Warning: mysqli_fetch_assoc() expects exactly 1 parameter, 0 given in line 20."

  12. this is a great tutorial a suggestion though you should add comments to your code that way we always have a reference to what is what

  13. Does anyone know how i would display an image for a specific search result? I tried using BLOB on phpmyadmin and it only displays text such as this: vsj(u͸-��0�k�h��b,sՀ��핻�f��(j!p�

  14. I could make it work this way:
    " $search = "%".$_GET['search']."%";

    $sql = "SELECT * FROM products WHERE brandProduct LIKE ?"; …"
    "… mysqli_stmt_bind_param($stmt, "s", $search);"

  15. how you make the search in the whole project in MVC model ?! I have struggle with that one, because the search can be exeucted on every single Controller of the page and I don't wanna have the same call in every single Controller I have for this project.. and certainly don't want the search being a static function, so how can this would be achieved ?!

  16. Thank you so much for your video tuts, they helped me a LOT during my traineeship. Keep up the good work, looking forward to more tutorials!


Please enter your comment!
Please enter your name here