PHP Tutorials: jQuery: Get Data from MySQL Database without Refreshing

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

КОМЕНТАРІ • 223

  • @benmontoya428
    @benmontoya428 9 років тому +7

    I've been watching your tutorials along with TheNewBoston's tutorials and I have to say you two are possibly the greatest teachers ever when it comes to programming. You guys are very descriptive and organized, and it's really easy to keep along and understand everything.
    Thank you.

  • @karlpokus
    @karlpokus 11 років тому +1

    I love that you start off your tuts with the result. Should really be a best practise. Kudos!

  • @SuperVegan1
    @SuperVegan1 10 років тому +5

    Very nice, no excess information and I understood it even though I've never done any php, thank you.

    • @codecourse
      @codecourse  10 років тому +1

      That's great to hear! Glad you found it helpful.

    • @proxdegracia6788
      @proxdegracia6788 9 років тому +1

      ***** sir gud am, how to make the display in table form

  • @LeviMr77
    @LeviMr77 9 років тому

    Holy mother of god! Just what I needed, I built the interbase version instantly as I was watching your video. Respect +++

  • @geeksicle314
    @geeksicle314 9 років тому

    The form would always refresh after using $_POST['submit'] in an if statement with the button. Now I see how to do this, because often times, the form submits multiple times and I get like 12 entires of the same information in my SQL Database! Thank you :)

  • @DorrellWilson
    @DorrellWilson 9 років тому +2

    I've been watching a lot of your videos, you're an excellent teacher.

  •  10 років тому

    Thank you! I had a problem, when i watched half of this tutorial i got the explanation!

  • @Patmanduu
    @Patmanduu 11 років тому +1

    Wow. Thanks for that. I WAS using single quotes in the query. Haven't touched the grave accents button in years (since high school French class).

  • @thesickbeat
    @thesickbeat 12 років тому

    Thank you for this. I'm not interested in ajax but this definitely helped me out ALOT with my school assignments.

  • @violinov
    @violinov 11 років тому

    Your tutorials are f*****g excellent man. Good job!

  • @obsdark
    @obsdark 10 років тому

    Excelent work
    But i have a question.., you see, i'm trying to do this with a PDO syntax, but in PDO you can't select the specific table of a db, so, how can i do it to AJAX search in the right table the information what i need?
    Thanks in advance

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

    How can this be integrated with a select function? Like

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

    Thank you! This wasn't directly what i was attempting to do, but this helped me to understand .ajax and .get/.post. Really really thank you.

  • @a55a51n2
    @a55a51n2 11 років тому

    followed your tutorial and it works great. how do i make it so that if i select a value from a select element it echoes the value in a text element of a form.?

  • @renesteneker9751
    @renesteneker9751 9 років тому

    Very nice guide. Any suggestions on how to implement such thing in laravel?

  • @jinixvomitorium
    @jinixvomitorium 11 років тому

    This is very helpful! also I am wondering how to transfer a $_GET from an index page to the jquery page that passes it to the PHP file that processes the query.

  • @shurui91
    @shurui91 10 років тому

    what if there is more than one Alex in the database with different locations? what part of the code needs to be changed?

  • @santunu23
    @santunu23 9 років тому

    Excellent tutorial neat and clean.I need a suggestion can i grab the fetch data into a input tag?

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

    the database connection and retrieval don't appear to apply anymore as i received a kinda obselute message. I got it working by using mysqli_connect, mysqli_query, and mysqli_fetch_assoc. I'm on WAMP server.

  • @sairajdas6692
    @sairajdas6692 5 років тому +1

    Is there any video preceding it? I can't figure out how the code works.

  • @bawbawsumhpa
    @bawbawsumhpa 9 років тому +1

    If I set input type="submit" in html page, data from the method $('div#name-data').text(data) just flash a millisecond and disappear. But this is not the case if I set the input type to "button" instead of "submit". But in your video, even though you set the input type to "submit", it seems to be working. Why is it that?

  • @lestevesl
    @lestevesl Рік тому

    Still useful after 11 years.

  • @nicoekkart
    @nicoekkart 12 років тому

    Isn't it better if you use submit instead of click. So you can also just press enter.

  • @22mawdizzle22
    @22mawdizzle22 12 років тому

    Just for some perspective, let's say I'm rendering 1000 markers that all have 10 pieces of data associated with them. I only want to bring back three pieces of data initially when I render the markers. But when a user clicks, I want to go get the other 7 pieces of data for just that marker.

  • @amitasthana
    @amitasthana 11 років тому

    Hey alex, i want to do the same thing, but i dont want to use the submit type button, i want it should give result as soon as i type in the box, maybe on page or a alert box, i know it can be done...., do you have some tutorial to explain this?

  • @joachimsome7228
    @joachimsome7228 9 років тому

    Great tutorial, it worked for me. I am a newbie and want to know how we can apply this to a form tag with different labels?

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

    Hi
    Nice tutorial
    Can you please help me with this? How to create divs automatically and populate them with records from your database

  • @VigilianceAurelious
    @VigilianceAurelious 12 років тому

    This is what I've really need on my thesis project! Thanks Alex! :D

  • @ThaRSGeek
    @ThaRSGeek 11 років тому

    How can I make it so it keeps checking if there is a new value posted in the db it automatically updates on the page

  • @venkman_uk
    @venkman_uk 11 років тому

    me too. doesn't work without. also finding that the name.php alert doesn;t work if you've put the inputs inside a form tag.

  • @niveenmahmoud7529
    @niveenmahmoud7529 11 років тому

    KingVentas is right
    also "POST" in "name" file should be in capital letters.
    it was not working with me bcoz of that as well!

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

    But how you can get row which is recently added without refreshing the page?

  • @22mawdizzle22
    @22mawdizzle22 12 років тому

    Alex, how would you fire the same type of AJAX to PHP reaction using Google Maps API V3? There is a listener event on a map marker that I can set to do something when the user clicks. So I want to do the exact same thing you did, but from the map. i.e. the user clicks the marker and my javascript sends my PHP the id of the marker clicked.

  • @danishjamil7677
    @danishjamil7677 9 років тому

    nice tutorial dude... but mysql to mysqli conversion is lil confusing now but yet nice video. keep on pumping out your tutorial contents, very informative and helpful for our career. ;)

  • @مقاطعمترجمة-ش8ث
    @مقاطعمترجمة-ش8ث 4 роки тому

    Fun fact that I'm moving slowly from PHP and web-developing to C/C++ and desktop developing , looks like I wasn't able to make any progress with it , I craving to my old days and my first language I learn C .

  • @MrGeekYass
    @MrGeekYass 9 років тому

    is there a Video on how to do the same thing but in Chat System without refreesh using Jquery ?

  • @Joshua_SZ
    @Joshua_SZ 11 років тому

    The tracking is very cool when executed, what's that? Firefox?

  • @TheMrChugger
    @TheMrChugger 12 років тому

    Chorley... What a beautiful part of the world!

  • @matte4749
    @matte4749 9 років тому +2

    What could the problem be?
    Warning mysql_num_rows().supplied argument is not a valid MySQL result resource in C:\AppServ\www\mywebsite\ajax
    ame.phpon line 11
    The code is the same as in the video.

    • @bluetastic405
      @bluetastic405 9 років тому +6

      Kitteh fan I had the same issue.What I used for the SELECT-statement was an apostrophe ( ' ). What he is using in the video is called a grave accent ( ` ). It looks very similar, but the apostrophe messes up the query. I hope that solved your problem! :)

    • @Nightzo
      @Nightzo 9 років тому

      +Mathias Buchwalder
      Thank you for helping me solve my problem!

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

      Incredible perceptiveness, thanks!

  • @TranceSerbia
    @TranceSerbia 9 років тому

    What if you do not want to echo out data in you php file ? Can you still send it back to jquery post method and use it ?

  • @pitocms
    @pitocms 10 років тому +8

    Awesome tutorial.

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

    Is there a C# version for this you can recommend? 🥺🥺🥺

  • @cvilee
    @cvilee 12 років тому

    Hey alex, nice tut but how would you get back multiple records and store them into table perhaps? Yea i know theres a lot of completed grids waiting just to be implemented, but i just wondering is there any way for us to make from scrach complete CRUD grid with jquery and ajax. Thanks alot for everything you've done so far

  • @rezefangz
    @rezefangz 11 років тому

    Is there a way to do this, except with a file, like a .txt or something?

  • @KingVentas
    @KingVentas 11 років тому

    Mine was not working and it's because a was using ' ' instead of `` when selecting db and table.

  • @hieronymus1981
    @hieronymus1981 11 років тому

    I always end up with a youtube video of this dude. I wonder.... Again cool stuff mate. !

  • @RQCKQN182
    @RQCKQN182 9 років тому

    Awesome video! Thank you!
    Please help me to alter my output so that it is processed. At the moment my output is just:
    31John.Smith
    How do I get it to output a proper row on a table? Does it relate to global.js line 5 at 9:38?

  • @naren77
    @naren77 12 років тому

    Hi Alex ,thanks for video,I have tried this,but it was not working for me,I Dnot have any errors also.Am unable to grab(output).....help me please...

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

    the javascript file is not working when it is in a seperate file...any ideas?? path is correct and its also not working with $(document).ready(function(){

  • @iSuperDuper
    @iSuperDuper 11 років тому

    hi alex , how can i make auto scrolling data from MySQL ? using jQuery

  • @schumibr1
    @schumibr1 12 років тому

    Can you make something like a loading image?
    I mean after I press the grab button a .gif will be displayed until de actual data is shown from the sql?

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

    Update with use of PDO. mysql/mysqli are obsolete. Otherwise, great tutorial.

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

    does it support html becoz i am taking pictures from database and want to show the them on frontend but its not happening

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

    I want to do like this but without button. I create a form. If I insert id from table product in text box, all information from table product will show up automatically in textbox product name, textbox product price. Then I can add more than one product in that form without submit it more than one time.

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

      you can use onkeyup or onkeypress....... if you want to do without clicking a button...

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

    I need help i want to use number to grab all the data on the row

  • @CantThinkOfNameOmg
    @CantThinkOfNameOmg 11 років тому

    In my name.php file I want to echo Test surrounded with paragraph tags. However, instead of my webpage display "Test" as a paragraph, it displays "Test" with the actual paragraph tags visible next to it. How can I echo "Test", but keep some paragraph tags on it?

  • @Colstonewall
    @Colstonewall 9 років тому

    The only thing I don't get is why use "===" in the if (isset($_POST['name']) === true && empty($_POST['name']) === false) part of the code?
    If you're just checking a boolean, why use the "===" tripe equals instead of double? Anyone?

  • @govinda678
    @govinda678 12 років тому

    Hi. In the previous version of this video, you used fadeIn() on the result div. It was pretty cool.
    How would you implement fadeIn() in your global.js file?
    Because this line does not work:
    $('#result').text(data).fadeIn();

  • @Rezzworks
    @Rezzworks 11 років тому

    Is yours not returning what is in the database? That's the problem I am having too.

  • @sebastianrodriguezcastella9528
    @sebastianrodriguezcastella9528 10 років тому

    How can I do that with a Dropdown select?

  • @neilharveyjaloog9341
    @neilharveyjaloog9341 11 років тому

    nice tutorial man !. , btw how to get 2 or more variables from database ? ex. i want to display age and location of the name i inputed in textbox . if i have age in database that is.

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

    Perfect explanation...

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

    Simple and awesome tutorial, I have done this similar tutorial using just php and MySQL, I did not include ajax.. Is it secure that way? but the way I don't have lots experience..

  • @AdikaAlchemist
    @AdikaAlchemist 11 років тому

    is it work with table within it?

  • @Asimov16
    @Asimov16 11 років тому

    Very good tutorial and I got it to work. Even upgraded it to MYSQLi too, but I have a different problem now. I want to out the values returned into a table with input forms which I have done with $('#partnumber').val(data); but I want to return more than one set of data eg part number and location. I tried two echos $row = $result->fetch_assoc();
    echo $row['PartNumber'];
    echo $row['Location'];
    but this returns it together. is there any way to return separate data? Hope I am clear

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

    Exactly what I was looking for. Thanks

  • @chrisread5445
    @chrisread5445 9 років тому

    This is a great video; watched it last week! Right now I'm trying to find how to populate a jstree with data from my MySQL database maybe using JSON (or maybe not) but Google has brought me back here! Does anyone know a video that will help me with what I want?

  • @Ones_
    @Ones_ 11 років тому

    Hi alex, what if the database is being update, how can we update the name.php without being refresh?

  • @SuperMegaStyle
    @SuperMegaStyle 9 років тому

    Nice tutorial! Thank youCodesource

  • @pagework60
    @pagework60 11 років тому

    Thanks I love all your tutorials.

  • @KingVentas
    @KingVentas 11 років тому

    Is it possible to retrieve more than 1 result, i.e. there's more than 1 Alex and I want to show All Alex Locations.?????

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

    Appreciate this vid! Very awesome.
    Can someone explain what I should do if I were to get an image file name from the MySQL table and display the image?
    Would it be an alteration in global.js :
    $('div#name-data').text(data);
    Or should the change happen in name.php?

  • @vincej151
    @vincej151 11 років тому

    Good example, - however the tutorial does not take the time to dissect what is really going on in the code which left me somewhat confused. To really understand what is happening in the code, with say for example the .post function then have a look at the w3schools documentation for the jquery .post function.

  • @meineroteBlume
    @meineroteBlume 9 років тому

    Very nice tutorial! Simply to understand. At the end of your video you post the mysql_result as an echo. Is it possible to post that over an $_POST to the HTML Page? I want to make a slider that always load the value of the database on the start.
    Sorry if my English is not quite right :)
    Greetings from Germany

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

    your connection form error, because mysql not work, now change mysqli

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

    Really good tutorial. But i am having one query and it is related with jquery. In my application, i am displaying users data in tabular format on a web page. One column contains username and other column contains a checkbox with value equals username fetched from mysql database. I have kept username unique. Below the table, i have taken a dropdown combo and one submit button. All this is embedded in a form.
    Now, depending upon multiple checkbox selection (i.e. multiple users selection) and single dropdown selection, i want to pass all usernames along with selected 'action' in the dropdown. The dropdown values contain Approve, Unapprove and Delete actions.
    If ''approve' is selected, then all selected users should receive an approval mail. Similarly for 'unapprove' it should happen. Is this functionality possible using jquery and also displaying approval / unapproval messages without refreshing the page.

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

      +Prashant Bedekar This is possible. You can send over all the users you selected and approve/unapprove to the server and have code there to either approve or unapprove all of them. Then the server could send a response with the users that were successfully approved or unapproved and you could handle that response in jQuery.

  • @RedouaneHammou
    @RedouaneHammou 11 років тому

    it's google chrome press F12 to see the page
    code

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

    Amazing tutorial, thank you!

  • @DanKardell
    @DanKardell 8 років тому +2

    Great job. I wasn't able to get my JQUERY to work unless I started it off with
    $(document).ready(function(){
    $('input#name-submit').on('click', function() {

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

      Savior! Thank you. :D

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

      i thought it was weird that he ommitted that. Yeah, ANY JQuery code should be wrapped in $(document).ready(function() { //code here });

  • @graham8377
    @graham8377 9 років тому

    Excellent video good job thank you.

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

    This is very useful video tutorial, thanks so much

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

    you've helped me a lot! Thank you for the awesome tutorial

  • @joshuadelfin7495
    @joshuadelfin7495 9 років тому

    sir can you upload a video... when the user type a keyword it will display automatically searched data into table format

  • @ZsolTuber
    @ZsolTuber 10 років тому

    Unfortunately AJAX+PHP is NOT working, when we use PHP classes :(
    Why not?

  • @CreativeDirektor1982
    @CreativeDirektor1982 12 років тому

    Very Good tutorial, very sample tnx!!!

  • @KimSalimVFX
    @KimSalimVFX 11 років тому

    how about without a button?

  • @dannyemmerik1556
    @dannyemmerik1556 9 років тому

    Thanks, I can now grab the output of my query and put this in a jquery dialog box. Only my problem is that the entire content that already exists in that div is now replaced with only the query output. Any help?

    • @koelekoetjes
      @koelekoetjes 9 років тому

      I myself am still learning, but you should be able to use .= if using php or += when using js/jquery to add on to the current content. Please correct me if i am wrong though.

  • @DomutaMarcel
    @DomutaMarcel 11 років тому

    An verry good tutorial for an begginer like me. Thanks :)

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

    you should use different variables names in "globe.js" file

  • @studentlife4851
    @studentlife4851 9 років тому

    Hi
    I am a beginner with this and I understand what is being done here but i want to be able to click on the grab button which will then in return give me the information from my database without having to type anything into a text box to receive information from my database .. I'm not sure if you have a tut for it already but yeah hope iv made enough sense

    • @AnhKim-sh5ef
      @AnhKim-sh5ef 8 років тому

      $.post('ajax/name.php',{name: "alex"})

  • @BramSebastian
    @BramSebastian 12 років тому

    can you tell me whatis wrong with my coding,
    i try to use your code but as result i always echo my entire name.php code
    can you give me clue ?

  • @mitagavit
    @mitagavit 10 років тому

    Thank you for the tutorial... was a great help

  • @xrandomteenx
    @xrandomteenx 12 років тому

    GOD i love this guy! He makes the awesome-est tutorials... i've learned a lot from you ALex! :D

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

    what if the data are stored in a postgre database? and you have to return an image?

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

      To return an image you can simply use the location and then reference the location + file name.

  • @talhakhan4608
    @talhakhan4608 9 років тому

    its soo use full thanks allot .

  • @aziaja
    @aziaja 12 років тому

    Can you please paste somewhere this code?

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

    You are great, many thanks

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

    Thanks it wouldve been so useful, but i always get the same errors when using the mysqli equivalents of the functions : /

  • @karlpokus
    @karlpokus 11 років тому

    would return (JSON_encoded obj) work as well as echo?

  • @CageyLastToKnow
    @CageyLastToKnow 10 років тому

    Many thanks for you help, what i wanted to do works now thanks to you :D