search bar using Php and MySQL
ฝัง
- เผยแพร่เมื่อ 29 ส.ค. 2018
- Hello Guys,
This video is on how to search for anything from the MySQL database using the search bar and displaying the search results using a table.
SOURCE CODE : www.dropbox.com/s/42s8mse7ts3...
Link to my Previous Videos
CURL Function and Making HTTP and HTTPS requests to browser : • CURL Function and Maki...
Retrieving Data From Database Using PDO object in PHP : • Retrieving Data From D...
Upload a File to MySQL Database using PHP : • Upload a File to MySQL...
Insert data into MySQL Database using PHP : • Insert data into MySQL...
Login Form In PHP And MySQL : • Login Form In PHP And ...
NCS: Music Without Limitations
NCS Spotify: spoti.fi/NCS
Download / Stream: ncs.io/blank
Want to use this track? Please copy & paste this into your description:
Song: Jim Yosef - Link [NCS Release]
Music provided by NoCopyrightSounds.
Watch: • Jim Yosef - Link | Hou...
Download/Stream: ncs.io/LinkYO
Thanks For Watching!
really nice and easy,ty!
you saved my back
may i ask how do you make the search much easier like if you only use some letters not whole and it will still pop the information in the search menu. thnxx
Bro, love the vid thanks so much for getting right to the point!! just a small question.. how can i show multiple records at once? it is only showing one record at a time?
if (isset($_POST["submit"])) {
$str = $_POST["search"];
$sth = $con->prepare("SELECT * FROM `users` WHERE profession = '$str'");
$sth->setFetchMode(PDO:: FETCH_OBJ);
$sth -> execute();
this is the code you have used, what should i change in the query??
hi, i get error on this
Parse error: syntax error, unexpected 'else' (T_ELSE) in C:\xampp\htdocs\CodeFlix.php on line 44. Can u pls help?
Cool! Try in this! Love
Thanks!
Hi! Your video was really helpful but i was wondering how can i open in php a html page when i am searching something?
Simple and straight to the point..
♥️♥️
thank you you helped a lot I am gonna save this video for one more time
I needed some help! I do not get any syntax errors but my code does not work online for some reason. It might have to do with using mysqli_connect instead of PDO. Do you have any idea how I can fix that?
Is db connected? If so is the query returning data?
you saved my life
thankyou so much 🙏
your The best ....your legend....thank u soo much ....much appreciated
♥️♥️
It Worked! Thanks
Brilliant tutorial. Here's a sub 👍👌
Thank you so much🙌
It works, thank you! :)
Yes🙌🙌
I have a problem displaying the error after I search sa data Uncaught Error: Cannot use object of type stdClass as array
great video, helped alot, thank you so much
Glad you liked it
?? why is it POST method instead of GET especially for search
Your life saver thanks a lot
How can I add pictures to my output?
Excellent! Thanks.
♥️♥️
thank you....it was very useful for my project
♥️♥️
HI, a quick question, is there a method where it can search the same thing but with less words? For example, in your vid, I'm searching for first name, but I'd like to search for it using the word 'first' only.
You have to change the query
@@CodeFlix12 i'd assume the query you meant is the table? problem is i have over thousands of entry and i don't think i can change them all
No not the table, the sql query which is used to search
Today, when I have time I will try and tell you if it worked for me! Thank you very much
Yes sir do tell me! It definitely works for others so surely it should for you! Let me know if you get stuck somewhere
Yes sir do tell me! It definitely works for others so surely it should for you! Let me know if you get stuck somewhere
@@CodeFlix12 Hi, it seems that so far everything works (I'm still at the minute 5:09) I was wondering where should I put the host name mysql password and mysql password
bro, help me please
You should put it at the top
this is perfect
❤️❤️
hi can you tell me where to make database because I don't know about php I'm designing a website with HTML/CSS but I need a working searchbar like this in my site.
Create one on phpmyadmin or download MySQL workbench and create one there
INSERT INTO 'search'('id','Name','Description') VALUES (1,'first name','Description of first name');
INSERT INTO 'search'('id','Name','Description') VALUES (2,'second name','Description of second name');
INSERT INTO 'search'('id','Name','Description') VALUES (3,'third name','Description of third name');
I enter the same codes as yours but mine is not working. Can you please help me, I'm almost dying thinking what error I've done :(
thanks a lot!!
how can i search for multiple keywords in more than one row at a time?
For example: the user is looking for a vet in Boston so he types "vet boston"
is there a way to search in the row where it specifies its a vet and in the row that specifies its in boston, separating the keywords and looking at multiple rows?
strlen like conversion i forgot
Hello sir, I'm very new to php and mysql, but I'm concerned about how secure is this method.
I need to create a search bar that looks for 'asset_id' insted of title,( main) id, name or description, so I guess that I should write ("SELECT * FROM 'dbname' WHERE asset_id = '$str'"), right?
Thanks in advance for the tutorial.
Yes right, and don't worry it is secure. To create more secure one try to create a stored procedure and run
There's possibility of sql injection
So instead you can use bind_param
🙌
@TheEnthraller how bout sanitize input?
veryyy niceee!
❤️❤️
any idea how to make the search bar chose a keyword from the name ? for example if the column name is "aaa bbb ccc ddd" and i search "aaa" it shows , bit lost
Yes it does the same
Great tutorial...
Thank you❤️
this isnt working it gives me a warning "Warning: Undefined property: stdClass::$Name" bruhhh🤦🏽
Why is the result not more than one even if it is using like
Thank you very good
Thank you too
Sir how can I use PHP and MYSQL only to build a site like Facebook what about the design of the site
What is the scale of the site you are thinking
9/10 videos only explain searching one column, need some more dynamic data inputs instead of just one Name column,but still thank you for your work
You just have to change your query likewise and you can get the same
Hye Sir, can i know what can i do if i want the search function to show videos?
You have to add tags in videos db table and search on tags
What results will show if I will search half word like only first
...
.. I want to make search that will return relative words of alfabates.
Try my ajax search and retrieval video
@@CodeFlix12 ok i will thnks
thank u very much
♥️♥️
The background ncs song hits different remind me of 2016 2015
Hey, thanks for the video.
I have one question : I can search for a (unique) 'username' in my table but how can I get the corresponding id of this username please? Knowing that it is in the same row
Thanks!
Just return id also when you search name
IN YOUR output Table Print the id as well
Name
Discription
ID
also do the same for the bottom line of code
ex.
♥️♥️
@@CodeFlix12 I realised I forgot to answer you back, sorry for that and thanks for the help !
🙌🙌
But what if I want to show search results in input fields
How I can do that?
Just populate input field with those values.
typing in SQL database doesn't work
can you help me?
code:
INSERT INTO 'search'('id', 'Name', 'Description') VALUES (1,'first name','Description of first name');
INSERT INTO 'search'('id', 'Name', 'Description') VALUES (2,'second name','Description of second name');
INSERT INTO 'search'('id', 'Name', 'Description') VALUES (3,'third name','Description of third name');
Try inserting manually in the table by right clicking on the table
try: _INSERT INTO `search`(`id`,`Name`,`Description`) VALUES (1,'first name', 'Description of first name')_ *you have done the wrong quotation marks/syntax*
i did as i see in the video but that what i get every time i click submit :
Fatal error: Uncaught PDOException: SQLSTATE[42S02]: Base table or view not found
Check table name
thank you very much
realy helpful
best tutorials ever
realy thank you
❤️❤️❤️
definitely does not work. I search and always get it does not exist - but the term does exist in DB. however, very few error checks in the code so I have no idea where the flaw could be
Error might be in bringing the data from the db with the SQL, either the term is going wrong or the data coming is wrong
thank you
❤️❤️
i have more than 1 row in my table but doesn't show each row with the same column name
Maybe you might have hard coded column names
hero
♥️♥️
Wow this works. How can I get the search results in another page?
keep going
❤️❤️
Thanks for a great tutorial... but can i search it using id, email or address? for now i only can search using name only
Yes you can
PDO does not work for me
when i'm done...i want to test , then i put my data in database, but it still said name does not exist...why ?
Check first in the db that the query you are using is returning any data or not. If not modify the query or db
Im getting the same error.
How do i check?
Run the query in phpmyadmin and see if the query returns any result
Uncaught Error: Call to undefined method mysqli_stmt::setFetchMode() in C:
Call to undefined method mysqli_stmt::setFetchMode() in C
I am using wamp and these are the errors showing
You have an error in your query, either in results coming or the query itself
Hi, is no show the error but cannot come out the data
Check is query returning data.?
it perfectly works. but can you help me to show multiple data in the table? because it shows one data match only. thank you!
Instead of = use like operator in sql query
@@CodeFlix12 can you show me the whole query please? i keep on getting errors. this would be so helpful to me.
What is the error? Because I don't have the query
I need search bar with category list please can you give me the code for it please
Can you explain me more on it
i tried it and it works but the search results are compact to each other, how do we give adequate spacing between each column
Just give and append a comma
Bro just used div and some bootstrap classes
to beautify it
Great sir
@@abukarieinus4745 Thanks bro
im getting Error
SQL query:
INSERT INTO `search`(`id`, `Name`, `Description`) VALUES (1,'first name' , 'Description of first name')
MySQL said: Documentation
#1062 - Duplicate entry '1' for key 'PRIMARY'
Try with Id 2 i.e (2, 'first name','desc')
tysm your code is really works
Yes! Other videos with such codes also do!! You can check them out also 🙌 thanks❤️
Bro, can you help me?
hard-questions.com/try/ggg.php it does not work
Can you tell me the error sir
@@CodeFlix12 I'm going to bed, I'm going to let you know tomorrow. Thank you for your availability
I want to make similar to search engine how to do that by using GET
Just pass the search parameter in the get api and you will get results which you can show
hello,
I want to buy this tools with paypal, can I pay for it with paypal?
Hello your code works just fine but it shows me only the first result of the sql command and i want all of them can you help me ?
Yes select all that match and run a simple loop over the results and it should work
@@CodeFlix12And how would you do that ? i tried to put a while($row = $sth->fetch()) and i gave me errors
@@CodeFlix12In the ? in the table ?
sorry to bother you i found the technique
Ok sure🙌🙌
I'm not able to run php file. It says access forbidden!
No it's not possible! You can email me and I will send you the PHP file. Or try to follow the steps from from the video to code. Thanks
@@CodeFlix12 Okay Thanks. It worked! Issue was with my XAMPP 😅
Okay great 🙌
How to display images along with product id using search query ?
You mean just like in an e-commerce website?
@@CodeFlix12 yes
I have a video on that
it doesnt show what ive searched. even its in the table
Check if the sql query is working
Hey bro! really educational video. But I don't know why I'm getting this error. Can you please help me out in it:
Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''search' WHERE Name = 'first name'' at line 1 in C:\xampp\htdocs\practice_2\index.php:27 Stack trace: #0 C:\xampp\htdocs\practice_2\index.php(27): PDOStatement->execute() #1 {main} thrown in C:\xampp\htdocs\practice_2\index.php on line 27
type using backtick quotes on `search` is different from 'search'
It work but only select one item form the search
can you please tell me what do you mean PDO
It is database object
Thank U Soooo
❤️❤️
Hi, i followed exactly however mine still doesnt work :(
What's error?
What the hell is the background music? Is this 2010 :DD Thanks for vid tho
🤣 I agree
can you make a video for search bar using html Php where it shows suggestion and also connected to Mysql
also filter sorting alphabetical order, numeric price high to low and so on?
Yep
hello is this object oriented?
No its not, but you always can convert :)
thank u bro
Pleasure!🙌🙌
how we can logout from the admin form perfectly and when we click on backword button of browser it goes into again in the admin without asking the password or username
By using session, new video on that coming up soon
@@CodeFlix12 waiting for it
Thanks man
How to show all the all the result? Not only the first one? Please help me
I have a video on that
@@CodeFlix12 whats the video called?
It is this video
When i put the url i get Error 404 not found
You might be putting wrong url, use naming convention like me
@@CodeFlix12 Hey I sent you messages on instagram
Please check your instagram
Please email me
@@CodeFlix12 I sent you an email please check it
Sure
The music is unnecessary and voice over would be preferred.
❤️❤️ thanks
Party!
❤️❤️
Hey what is dbname
CodeFlix
@@CodeFlix12 Hey check your Instagram
php code not workingwhen i run it with boootstrap framework..need help!!
What error does it show?
@@CodeFlix12 i have solved that..but now i want to get multiple rows which matches the search..hut i am getting only the first match.
Any idea on whether to apply foreach loop or any other?
It will get you multiple rows sir, fill multiple data in it
@@CodeFlix12 no it is not getting
@@CodeFlix12 i'll mail you the code; can u look in to it?
how to do this thing in 000wehostapp.com can you make video for how to do this search like from 000webhostap.com data manager.
Sure
i wanna cry, it doesn´t work. dont show the results
Is it throwing any kindof error or something? Because That's not possible because it's working perfectly
@@CodeFlix12 yeah it doesn't work for me and no error show. why?
Does the table have data? Did you search for correct results
Same thing happening to me. How did you fix this?
Problem in query maybe
hello friend, 500 error pops up
oh, figured it out, wrong db name))🤪
thank u for giving this - www.dropbox.com/s/42s8mse7ts32hys/index.php?dl=0
love u bro
thank u
u are the best php youtuber
roses are red
sky blises blue
you are the best
all love is for u
❤️❤️
hey can you make it same for autocomplete search...thank you for this also..it worked!!^_^
❤️❤️
bro this does not work are you there ?
Yes brother I am here for your help!! What error does it show?
@@CodeFlix12 when i try your codes nothing happens brother
Any error thrown in the console or something? If not, I guess the SQL you are implementing is not working as per requirements
Did you follow my exact same code? I tried it right now and it's working for me brother! Let me know if I can help
@@CodeFlix12 i send you tommorow i go sleep now its 00:27 here NL
Errroooorrrr 👎👎👎
Which part? Or what error?
👎👎👎👎👎👎👎👎👎👎👎👎
❤️
That's just how I work
@@CodeFlix12 Your expression is very complicated.
If you don't understand it doesn't mean it's complicated
@@CodeFlix12 okAy
Thanks you very much
❤️❤️
thank you
♥️♥️