PHP Tutorial: Make a simple search engine MySQLi (1/2) | Simple Search Code in PHP with Demo

preview_player
Показать описание
*** Download the Source Code for FREE: ***

Learn how to make a search engine in php. This simple search engine uses a MySQL database and php arrays to search through the results in the database, based on the keywords entered in the form.
- In part 1, we create the entire search engine and connect it to the database.
- In part 2, we create the add entry form to easily add new entries into the database.

Read the article on my website:

_________________________________________________________________

Learn more PHP, MySQL, and HTML programming:

Need to change your phpMyAdmin or MySQL account passwords?

__________________________________________________________

Рекомендации по теме
Комментарии
Автор

Some good components but some side notes.
1. The trim() function does NOT remove spaces inside of a string. ' This sentence ' will trim as 'This sentence' and not 'Thissentence'. The trim() function only removes from the beginning and end of a string. Of course in this code that's perfect because later we use explode() which relies on this exact case. Just clarifying as the wording may confuse some viewers.
2. The substr portion needs refinement.
Instead of using strlen just use substr($query_string, 0, -3). Substr has this built in already where -3 at the end pulls all EXCEPT the last 3.
3. For the search words, you could just send back the GET variable to show what the user searched for, or even trim($_GET['k']) to be exact. I'm not sure I understood why the output is being rebuilt into $display_words. However, your method might be useful if we're excluding, for example, banned words. In this case, we could end up only adding back accepted words that were searched. If that was the case, then 100% this isn't a bad idea. You could even replace any prohibited words with an asterisk or asterisks to indicate that this word was excluded from the search.

4. I know this was just an example, but I still think it's important to talk about security. Users should never be trusted. Please if reading this, remember to always clean up user inputted data. In a best case, you'd use prepared statements and/or be very strict with accepted input.

ChrisB_
Автор

Great information! One question though: What if you wanted to have each full record that gets returned, appear on its own line/tr? How would you do that without duplicating the results?

joshdavis
Автор

wow this will help me a lot for my project... i like your information... such great tuturial. thank you!

leomascardenio
Автор

hello i cant download the source code IDK why

aldrenbayaban
Автор

Why it's showing no results found when I runs it?

ansh
Автор

Yup the download checkout hangs for me too. Very disappointing! Could you not make it so we can just download it from a simple link without the cart nonsense?

chrisdorsay
Автор

This tutorial is well designed. Great job!
I have trouble figuring out how the while loop works at 25:26
Could anyone break it down or explain? Thanks!

ga
Автор

Hi, wonderful code but i am unable to download, Please can you help with the link as the other page download link to the basket dose not work. Thank you

salimmiah
Автор

Mysqli_num_rows() expects parameter 1to be mysqli_result, bool given in ..
This type of error coming in what can I do..is it is because of php version 7.3.20..???

_pradeepyadav
Автор

THANKS SO MUCH MAN! I just followed your tutorial and got my Sybase SQL Anywhere database connected with your code to a website !!! Please do more like this :'( I will add more things to it like Icons on the Left side of each title that appears. I will look for info like yours to do it Im starting to learn this!

xavierpersal
Автор

I cannot access the source code. Your checkout page hangs.
c-ajax=checkout:1
Failed to load resource: the server responded with a status of 524 ()
It would have been easier to provide a simple download link to a zip file imho :/

TheEndOfMadness
Автор

Hi can you give me an example of how the ellis model is used in this? Btw thank you very much

revlmp
Автор

Hoping to get the source code even if it's just the css

accountaccount
Автор

Hi I am not able to download.Could you please assist.

arunraviunni
Автор

HeyTuts, could you make part 3, to addpagination to part 2, please?

NedumEze
Автор

Great tutorial!, how can i do this same example but searching in diferents columms in the same table so rich the result ?

ramirobustos_ok
Автор

Dude any thoughts on how to build a php search engine that can search 2000 html pages for words or phrases ? I was thinking you would have to do something with concurrency ? Let me know your thoughts please

Cognitoman
Автор

how to create pagination to this search bar?

ramaraonara
Автор

Bro this is insane! also, is there a way to make it only show results if the search matches with an entire keyword and not just a letter in the key word because right now if I type in let's say "a" it will come up with minecraft because the keyword sandbox has an a in it.

DIBLIC
Автор

great code. I was wondering is there a pagination code for this? I found some online, but to be honest I am getting errors when I implement, so I gave up. Only that I did for the moment is limit to 100 results.

sinisastrosar