How to Build a Website #4 - Creating a WORKING Search Bar [Part 2] [PHP & MySQL]

Поділитися
Вставка
  • Опубліковано 9 лис 2024

КОМЕНТАРІ • 190

  • @MrKasbaros
    @MrKasbaros 7 років тому +6

    OMG! You have just saved my life with this... Being new to php yet I have a project to deliver soon... Thanks a lot

  • @zareenremendies
    @zareenremendies 4 роки тому +1

    One of the finest channels on UA-cam

  • @ajoymaitra521
    @ajoymaitra521 4 роки тому +1

    Thank you very much... appreciate the way you have explained the steps of php and database linking...

    • @hazirahmusa2840
      @hazirahmusa2840 4 роки тому

      can you share the code? im having trouble Hazirah_musa104@gmail.com

  • @hemantmarasini326
    @hemantmarasini326 3 роки тому

    Thanks for your help man...😊
    Nice video..👍👍

  • @thuweinthabit6313
    @thuweinthabit6313 7 років тому

    Up to this stage, you helped me solve my problem with a search bar. Thank you

    • @hazirahmusa2840
      @hazirahmusa2840 4 роки тому

      Hi, can you share the code? I really need it for search engine

  • @mohamedmusthafa.v1738
    @mohamedmusthafa.v1738 4 роки тому +2

    I think that this mysql code is now outdated. Can you please teach how to make a professional search bar using the new code of mysql.🧐

  • @creativeakshara8438
    @creativeakshara8438 4 роки тому +1

    Thanks 😊 It helped me a lot 😁

    • @hazirahmusa2840
      @hazirahmusa2840 4 роки тому +1

      do you have problem on undefined variable 'q'?? can you help me?

    • @creativeakshara8438
      @creativeakshara8438 4 роки тому

      @@hazirahmusa2840 I don't know this
      As I don't copy the Code. I Just wanted to know the way to do this.
      And I did everything by myself.
      But I can help you??
      What is your problem

    • @hazirahmusa2840
      @hazirahmusa2840 4 роки тому

      @@creativeakshara8438 can I email you the code that im currently doing? Im kind of lost T_T

    • @hazirahmusa2840
      @hazirahmusa2840 4 роки тому

      @@creativeakshara8438 at first i was having error on undefined variable q then i tried some code to declare it then it says syntax error, unexpected end of file

    • @creativeakshara8438
      @creativeakshara8438 4 роки тому

      @@hazirahmusa2840 Please paste your code here

  • @campodasexatas5370
    @campodasexatas5370 4 роки тому

    Thank you! This video has helped me a lot!

  • @kyrababieee914
    @kyrababieee914 7 років тому +4

    Hey. This is my first time outside of html/css/js. This is seeming like I need something extra to do this. What exactly do I have to download (if anything) to make this work? Thanks.

  • @rajsekharsharma8199
    @rajsekharsharma8199 6 років тому +1

    Can u make an video on DBMS for search bar.

  • @JoeDracup
    @JoeDracup  8 років тому +7

    If you need any personal help with your code, such as bug fixes or if your code isn't working as it should do, or perhaps if you would like a complete, professional website creating for you from scratch? Send me an email at joseph.dracup1997@gmail.com and I'd be more than happy to help out :).

    • @parmodsaha8733
      @parmodsaha8733 7 років тому

      can you implemented search box with my desire query??

    • @zenofficial736
      @zenofficial736 7 років тому +1

      how do you get the local host plz help asap

    • @arushijain9563
      @arushijain9563 6 років тому

      Hey, can you tell me something about meta tagging?

  • @neetu2810
    @neetu2810 7 років тому

    Hi, i know this is pretty old video but i hate to watch these vids because of one reason. I have mysqli installed and i don't know if that makes much difference or a lot of difference in the code. Is the thing here only about in the $con attribute, that i change it to $con = mysqli_connect, or do i have to make more changes? Also, from now on, make videos also explaining this side of the code for those who have mysqli.

  • @snspro8223
    @snspro8223 8 років тому +15

    Can i get source code???
    Just asking...................... ;)

    • @hazirahmusa2840
      @hazirahmusa2840 4 роки тому +1

      can you share the code? im having trouble Hazirah_musa104@gmail.com

    • @evan.5967
      @evan.5967 4 роки тому +1

      @@hazirahmusa2840
      Hi 👋,
      No.
      Let me know what error the console returns, and I'll help. 🙂
      Let's "teach you fishing; not giving you fish." 👍
      ~ Evan

  • @zaurmahmudov1438
    @zaurmahmudov1438 7 років тому

    That's really cool. I found that really helpful.

  • @vijaymanoharlokale4351
    @vijaymanoharlokale4351 4 роки тому

    superb!!! awsome !!! no words

  • @newsmix8659
    @newsmix8659 4 роки тому

    Very informative! keep up the good work pal! Now, how can one add a google-like paging system to the above s.engine! Perhaps you can create a similar video together with paging system added to it. Thanks.

    • @hazirahmusa2840
      @hazirahmusa2840 4 роки тому

      can you share the code? im having trouble Hazirah_musa104@gmail.com

  • @jayshah8420
    @jayshah8420 7 років тому

    great video mate!! quick question where to learn php.. any online source or books? make more!!!

  • @tellytelly6752
    @tellytelly6752 5 років тому

    I am missing something in between. Are you still opening the original index.html file to view the search results?

  • @zhopnik1917
    @zhopnik1917 5 років тому

    Thanks again, Joe. Super tutorial. All I gotta do now is get a ton of text/.pdf docs into a database.... er.... I guess. Fingers crossed (which make it awkward to type :)
    John

    • @hazirahmusa2840
      @hazirahmusa2840 4 роки тому

      Hi can you share the code? I really really need it T_T

  • @ankle_bells
    @ankle_bells 2 роки тому

    Thankyou for your tutorial.. But Its giving me undefined q. How to resolve that?

  • @tomj9107
    @tomj9107 7 років тому +1

    Thank you so much for this tutorial. It was very helpful!

    • @hazirahmusa2840
      @hazirahmusa2840 4 роки тому

      can you share the code? im having trouble Hazirah_musa104@gmail.com

  • @cridane7431
    @cridane7431 7 років тому +2

    can u teach us ow to publish it to the web

  • @capt_ndereya
    @capt_ndereya 4 роки тому

    one of the best videos though i had to modify some stuff and am also using MYSQLI

    • @hazirahmusa2840
      @hazirahmusa2840 4 роки тому

      can you share the code? im having problem T_T

    • @hazirahmusa2840
      @hazirahmusa2840 4 роки тому

      it can be a big help for me T_T because im having error on undefined variable 'q'

    • @evan.5967
      @evan.5967 4 роки тому

      @@hazirahmusa2840
      Hi,
      there is an answer two comments above this one.

  • @marchardchance2170
    @marchardchance2170 5 років тому

    you dont show all tutorial totally as well as possible xo try u're best thank u!!!!!!!!!!!!!1

  • @aredditua
    @aredditua 7 років тому +2

    How do you get the php tables?

  • @AdelinBonheur
    @AdelinBonheur 5 років тому +3

    Undefined variable: q. how can I fix it?

    • @nikolamitrevski1535
      @nikolamitrevski1535 4 роки тому +1

      SOLUTION:
      .
      .
      .

    • @rodelcatapia16
      @rodelcatapia16 4 роки тому

      @@nikolamitrevski1535 Wow cool tis resolved my issues. But could elaborate as to why I was getting the error? Thanks in advance

    • @prajwalshetty9968
      @prajwalshetty9968 4 роки тому

      @nikola 4th and 5th line is really confusing.... Can you be more specific... Please

  • @portlandsound1
    @portlandsound1 8 років тому +5

    Hi there, do you have the source code you created during this video to share?

    • @evan.5967
      @evan.5967 4 роки тому

      Hi 👋,
      No.
      Let me know what error the console returns, and I'll help. 🙂
      Let's "teach you fishing; not giving you fish." 👍
      ~ Evan

  • @markgrindey3325
    @markgrindey3325 8 років тому +1

    I have all the code correct I'm sure however I don't get any results when I press search

  • @superscribe6651
    @superscribe6651 2 роки тому

    Where di you go over the q variable? Mine doesnt understand the 'q'. Sure its a name but it doesnt understand.

  • @cristif92
    @cristif92 7 років тому

    Nice one ! :)
    I have only one question : how I can hide the password and/or the username of my database in the index.php to not be seen by those who click right on mouse, and can view my page source ? ;)

    • @spammr
      @spammr 6 років тому

      Cristian Florescu Ask google...

    • @sabarimanikandan19
      @sabarimanikandan19 4 роки тому +1

      Use post method

    • @evan.5967
      @evan.5967 4 роки тому +2

      I don't believe you can view PHP in "View Page Source"

    • @cristif92
      @cristif92 4 роки тому

      you are right evan. I was more dumbt back then. :D

  • @ThankfullCheese1
    @ThankfullCheese1 7 років тому +1

    can you link the code in the description so people can just copy it

  • @colinlaganier2966
    @colinlaganier2966 7 років тому

    Hi, how could you change your code so that it would look for the word(s) you input on your website and show you on which page it is?

    • @evan.5967
      @evan.5967 4 роки тому

      You got the basics, now use the knowledge of PHP to expand on that! 🙂

  • @masteringmaths
    @masteringmaths 7 років тому +1

    I want my search bar to appear on my index.html page. Can I change it to a php file?

    • @sharifabahar6257
      @sharifabahar6257 7 років тому

      sure can just save as it and change the .html to .php suffix.
      but the php file (the one with .php) must be saved within htdocs folder which is the folder that you installed XAMPP or any phpmuadmin.
      i hope it help you .

    • @masteringmaths
      @masteringmaths 7 років тому

      ok thank you

  • @tahirmahmood1721
    @tahirmahmood1721 4 роки тому

    Hi my pages don't seem to work. I have done the code same as yours. But when I open my index.html and run it on chrome. When i click on the other pages nothing happens. Am so frustrated. Any help would be appreciated.

  • @jobseer7387
    @jobseer7387 3 роки тому

    🙌🙌

  • @soumyaappugouda4676
    @soumyaappugouda4676 6 років тому

    how to write for the keyword search? for ex: when we write any word on search-bar regardless case sensitive word should popup from content of body tag

  • @Nonpor4317
    @Nonpor4317 8 років тому +1

    where did the q varaiable come in

  • @toy9437
    @toy9437 7 років тому

    nice

  • @dibraniuk
    @dibraniuk 5 років тому

    perfect

  • @nholmes86
    @nholmes86 6 років тому

    where i can download???..give the link please

  • @hazirahmusa2840
    @hazirahmusa2840 4 роки тому

    i got error T_T can you make another one with current version??

  • @Dcode103
    @Dcode103 5 років тому

    Can we do this only in HTML file without PHP files

    • @evan.5967
      @evan.5967 4 роки тому

      No.
      You can still put HTML code in PHP so long as you follow the PHP formatting

  • @akcreater4998
    @akcreater4998 5 років тому

    Good morning Sir very good video Hindi me ek video create kijiye Jo ki 2 field ka search bnaeye first select city after second search keyword input field php7.2 me mysqli

  • @RyanCummings807
    @RyanCummings807 4 роки тому

    how do I get the database thing in the beginning

  • @rick8602
    @rick8602 7 років тому

    All my text/entry fields do not work on my wordpress website. Eg. my search bar doesnt allow me to type anything. Also, my checkout billing information form wont allow text. Someone help!!!

  • @pravinsurve1867
    @pravinsurve1867 5 років тому

    I'm getting the error are
    Unexpected'if(T_IF)
    Please tell me solutions above the error

  • @coreinteresting8511
    @coreinteresting8511 8 років тому

    How did you make the six record for the database? 2:10

  • @orc13a
    @orc13a 7 років тому

    pls say how to set up the database

  • @ememparafina8696
    @ememparafina8696 4 роки тому

    Hello, The javascript on search bar does not work.

  • @anshumanpattanayak1514
    @anshumanpattanayak1514 6 років тому

    Notice: Undefined index: q in C:\xampp\htdocs\pratice\search\index.php on line 2

    • @JoeDracup
      @JoeDracup  6 років тому

      Anshuman pattanayak Hi! If you need help with this I’m sure I can help you out! Please email me at: joseph.dracup1997@gmail.com for assistance. Thanks!

    • @JXHNDRX
      @JXHNDRX 5 років тому

      Same here...

  • @NinhTran09
    @NinhTran09 3 роки тому

    🚀🚀

  • @SweatySockGaming
    @SweatySockGaming 7 років тому +1

    Does anyone know how to center the search bar? Thanks in advance

    • @alphagamerhd3148
      @alphagamerhd3148 7 років тому

      Riyan Ahmed
      The search bar contents go here

    • @evan.5967
      @evan.5967 4 роки тому

      @@alphagamerhd3148
      I would personally use CSS to center it, but that should work too.

  • @heezymane340
    @heezymane340 7 років тому

    Hey Joe, i was having an issue with linking the search bar to my webpage. It would give me an error as well as my database taking in new usernames and passwords. It accepts the admin information just fine. I just emailed you as well and if anyone sees this and can help I'd appreciate it as well. Thank you.

  • @zanoonqureshi5777
    @zanoonqureshi5777 6 років тому

    where do i get this code

  • @chandann2343
    @chandann2343 8 років тому

    thanks you @ jeo dracup ...i was searching the exact thing..
    plz mail me the code.

    • @hazirahmusa2840
      @hazirahmusa2840 4 роки тому

      can you share the code? im having trouble Hazirah_musa104@gmail.com

  • @NinhTran09
    @NinhTran09 3 роки тому

    🌟🌟🌟

  • @kiszatay6149
    @kiszatay6149 4 роки тому

    The DB connection wasn't working for me but i fixed it. For the search box why don't you put required in it ?

    • @hazirahmusa2840
      @hazirahmusa2840 4 роки тому

      Hi can you share the code? Im having trouble and examination coming very sooon 😭

    • @kiszatay6149
      @kiszatay6149 4 роки тому +1

      Don't remember exactly what I did but I think I use:
      $s = $_GET['S');
      $host ="localhost";
      $dbname ="test":
      $dbusername= "root";
      $dbpassword = ' ';
      $con= mysqli_connect($host, $dbusername, $dbpassword, $dbname);
      For the start then for the query:
      $query = mysqli_query($con, "SELECT * FROM books WHERE title LIKE '$s' ");
      $num_rows = mysqli_num_rows($query);
      Tell me if it works

    • @hazirahmusa2840
      @hazirahmusa2840 4 роки тому

      @@kiszatay6149 i already done that.. but it says undefine vaeiable q..

    • @kiszatay6149
      @kiszatay6149 4 роки тому

      @@hazirahmusa2840 what are you using 'q' for ?

    • @hazirahmusa2840
      @hazirahmusa2840 4 роки тому

      @@kiszatay6149 let me send the code..
      @Creative Akshara

      body {
      font-family: arial;
      }
      h3 {
      margin: 20px 0px 0px 0px;
      padding: 0;
      }
      h4 {
      margin: 10px 0px 0px 0px;
      padding: 0;
      }
      p {
      margin: 5;
      padding: 0;
      }
      a {
      color: #000000;
      text-decoration: none;
      }
      a:hover {
      color: #000000;
      text-decoration: none;
      }

      Search


      function active() {
      var search = document.getElementById('searchBar');
      if(searchBar.value == 'Search...'){
      searchBar.value = ''
      searchBar.placeholder = 'Search...'
      }
      }
      function inactive() {
      var search = document.getElementById('searchBar');
      if(searchBar.value == ''){
      searchBar.value = 'Search...'
      searchBar.placeholder = ''
      }
      }

  • @federicobau8651
    @federicobau8651 4 роки тому

    Man the mismatch between the mouse pointer and the selection run me crazy

  • @JXHNDRX
    @JXHNDRX 5 років тому

    Holy shit guys I got it. The fix for the undefined q is
    $search = (isset($_GET['q']) ? $_GET['q'] : null);

  • @stephenhancox698
    @stephenhancox698 8 років тому +11

    I'm getting the following error message - Notice: Undefined index: q in C:\xampp\htdocs\lexicon\search_bar
    av.php on line 2
    Any ideas?

    • @dhegana
      @dhegana 8 років тому +3

      same i got the same error... I already use mysqli. can u help us Joe. thanks

    • @grzegorzorowicz7935
      @grzegorzorowicz7935 8 років тому +6

      have anyone solved problem with undefined index: q?

    • @cristif92
      @cristif92 7 років тому +5

      Finally, I resolved this ! :) It's so simple that you would not think of it :D
      On the part when you have something like this one :
      if($_GET['q'] !== ''){
      DEFINE ('DB_USER', 'your_user'); // here I prefer to define user, password, host, and database, to not get confuse during the code :D
      DEFINE ('DB_PSWD', 'your_password');
      DEFINE ('DB_HOST', 'your_host_name');
      DEFINE ('DB_NAME', 'your_database');
      $dbcon = mysqli_connect(DB_HOST,DB_USER,DB_PSWD,DB_NAME) or die(mysql_error());
      $query = mysqli_query($dbcon, "Select * FROM searchBar WHERE Titlu LIKE '%$search%' OR Descriere LIKE '%$search%'"); // As you can see, I use $search instead q, for every column from my table searcBar ;)
      $num_rows = mysqli_num_rows($query);
      // and so on ...
      }
      and before this add
      $search = $_GET['q'];
      One more think ... maybe two more thinks :
      1. don't forget to check if you have method="GET" on your index page, and GET as well on your php page.
      2. I added this code after the input field, to have a defined index util the php code ;)

    • @tomj9107
      @tomj9107 7 років тому

      I'm new to PHP and I spent so long trying to fix this. Didn't know it was so simple. Thanks a lot!

    • @novatech9832
      @novatech9832 7 років тому

      you're right man I also did it that way because I'm also using mysqli however, the following part of the code, I only were able to make it run without the else statement:
      $q = $_GET['q'];
      if($_GET['q'] == 'Search...'){
      header('Location: index.php');
      } else {
      header('Location: Index.php');
      }
      by any chance do you know how to make it work with the else statement?

  • @sajjangamer
    @sajjangamer 7 років тому

    how do you add a logo in the top corner i need help with that.

    • @evan.5967
      @evan.5967 4 роки тому

      Hi 👋,
      You can do the below tag in the section of your HTML.
      That should work; if it doesn't feel free to reach back and list what is wrong with the positioning of the image 🙂
      Hope this helps 👍
      ~ Evan

    • @sajjangamer
      @sajjangamer 4 роки тому +1

      @@evan.5967 3 years later, thanks. I've been waiting this whole time.

  • @gamerninja3048
    @gamerninja3048 7 років тому

    how we can set php in local server please help

  • @markgrindey6306
    @markgrindey6306 8 років тому

    do you need any javascript code for this if so could you send copy. if not would you be willing to make our site search work for payment obviously.

    • @JoeDracup
      @JoeDracup  8 років тому +1

      Hi Mark, email me at joseph.dracup1997@gmail.com. I'd be happy to make sure your website works 100% for payment :).

  • @aashishthakur6509
    @aashishthakur6509 6 років тому

    Plz send the link of your code

  • @zephyr5948
    @zephyr5948 4 роки тому

    RIP Brother

  • @jimmyw6324
    @jimmyw6324 7 років тому

    How do I create my own database? I'm confused how you start off the video with one already.

    • @evan.5967
      @evan.5967 4 роки тому

      Hi 👋,
      You can make a database with PHP. 👍
      You can use XAMPP to build a database.🙂
      ~ Evan

  • @okboss8658
    @okboss8658 7 років тому +1

    give me this save file

  • @BLkfrost411
    @BLkfrost411 7 років тому

    How do i search an alphanumeric text
    for example i want to search an invoice number
    IN83766
    i want it to find that text
    and display the full row its connected to
    i only managed to find normal numbers for some reason and it displays its row , please can someone help me
    this is the line of code i use now
    $disp = mysql_query("SELECT First_Name, Surname, Email, InvoiceNumber FROM test WHERE InvoiceNumber= $invoice");

  • @Mmamaster594
    @Mmamaster594 4 роки тому

    How do insert records into the database?(2:12)

  • @buddytv4088
    @buddytv4088 6 років тому

    Mach vlogs

  • @coderflowerdev
    @coderflowerdev 4 роки тому

    How ti write the localhost code? :(

  • @bryanmanalac5196
    @bryanmanalac5196 7 років тому

    button "GO"??

  • @su-1337
    @su-1337 5 років тому

    you never defined $q in this how is this working??

    • @hazirahmusa2840
      @hazirahmusa2840 4 роки тому

      im having this problem also!! do u solve it already?

  • @rangefighter276
    @rangefighter276 7 років тому

    can any one give the total source file on my dropbox id or gmail?

  • @redeye5075
    @redeye5075 4 роки тому

    undefined function mysql_connect() HELP

    • @lingard533
      @lingard533 4 роки тому

      try this
      $con=$link=mysqli_connect("localhost", "root", "")
      $db=mysqli_select_db($link,"databasename")

    • @hazirahmusa2840
      @hazirahmusa2840 4 роки тому

      @@lingard533 do you have problem with undefined variable 'q'?

  • @basicslee101
    @basicslee101 4 роки тому

    Hey everyone just wanted to say in the line
    it is actually-
    that is why no results come

  • @fernandomunoz-najera8634
    @fernandomunoz-najera8634 7 років тому

    i got error: Undefined variable: q on line 79

    • @kalipr9506
      @kalipr9506 7 років тому +1

      So did I. Did you end up finding out how to fix it? Let me know if you did :p

    • @rawansager1626
      @rawansager1626 6 років тому +1

      Me to :(

    • @prajwalshetty9968
      @prajwalshetty9968 4 роки тому

      Did you guys fixed the errors? 😔

  • @novatech9832
    @novatech9832 7 років тому

    I only were able to make it run without the else statement:
    $q = $_GET['q'];
    if($_GET['q'] == 'Search...'){
    header('Location: index.php');
    } else {
    header('Location: Index.php');
    }
    I'm using MySQLi, by any chance someone can tell me how to make it work with the else statement?
    thanks before hand

    • @hazirahmusa2840
      @hazirahmusa2840 4 роки тому

      can you share the code please? im having trouble

  • @evanbrealey
    @evanbrealey 8 років тому +1

    This is so confusing! What do I do if I don't use localhost

  • @09_pradeepyadav83
    @09_pradeepyadav83 4 роки тому

    Please provide source code.... please.. please.. please..!!!!

  • @shroom2018
    @shroom2018 7 років тому +1

    PLEASE TELL ME HOW TO GET MYSQL AND PHPMYADMIN BECAUSE ITS VERY HARD

    • @Ethan-uf4wq
      @Ethan-uf4wq 6 років тому +1

      Okay, i know its been more then ten months, but i have the video discription to geting mysql,
      ua-cam.com/video/kVc_9vAO7oI/v-deo.html

    • @spammr
      @spammr 6 років тому

      Shroom2018 Before you get MySQL, learn HTML, CSS and Javascript

  • @mandylogan900
    @mandylogan900 7 років тому

    Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in how to solve this error please help thanks in advance

  • @DMT-bf2lp
    @DMT-bf2lp 7 років тому

    This is The Fake Video

  • @mickmackusa3349
    @mickmackusa3349 7 років тому

    OMG! No! Everyone STOP WATCHING THIS! Go learn something modern like mysqli or pdo. mysql_ functions are dead forever.

  • @bracagameribd2291
    @bracagameribd2291 7 років тому

    It doesn't work there are 1 million errors