Deprecated: Function create_function() is deprecated in /var/www/vhosts/ on line 70
json tutorial for beginners part 7 Ajax PHP MySQL Data Request Programming |
  • Saturday , 24 October 2020

json tutorial for beginners part 7 Ajax PHP MySQL Data Request Programming

Code Canyon

Lesson Code: Part 7 of learning JSON for beginners with Adam. In this final lesson of the series…

Original source

3d Ocean

Related Posts


  1. Blu Strikes
    March 22, 2018 at 20:42

    HI, which "json" file did you use for this particular tutorial? Sorry, I must have missed it. I did follow all your other JSON tutorials previous and post, but never saw the JSON file used for this particular tutorial. Trying to use my gallery JSON file and nothing is working. I've had much success till now with all your other tutorials I have followed. Can you help me with this one. Thanks.

  2. kogei bett
    March 22, 2018 at 20:42

    whats with the bot voice smdh

  3. EduKSA
    March 22, 2018 at 20:42

    Please note that the SQL code in here is depreciated and will not work with new php. You can find equivalent code by googling php sql and finding the code there.

  4. Aditya Gadi
    March 22, 2018 at 20:42

    plz tell whats wrong in this im not getting the output…its just show redirecting


    header("Content-Type: application/json");
    $limit = preg_replace('#[^0-9]#', '', $_POST['limit']);
    $i = 0;
    $jsonData = '{';
    $sqlString = "SELECT * FROM users ORDER BY RAND() LIMIT $limit";
    $query = mysqli_query($db_conx,$sqlString) or die (mysql_error());
    while ($row = mysql_fetch_array($query)) {
    $id = $row["id"];
    $name = $row["name"];
    $pass = $row["pass"];
    $jsonData .= '"person'.$i.'":{"id":"'.$id.'","name":"'.$name.'", "pass":"'.$pass.'" },';
    $jsonData = chop($jsonData, ",");
    //$now = getdate();
    //$timestamp = $now[0];
    //$jsonData .= '"arbitrary":{"itemcount":'.$i.', "returntime":"'.$timestamp.'"}';
    $jsonData .= '}';
    echo $jsonData;

    html file

    div#databox {
    background: #F3F3F3;
    border:#CCC 1px solid;
    var myTimer;
    function ajax_json_data(){
    var databox = document.getElementById("databox");
    var arbitrarybox = document.getElementById("arbitrarybox");
    var hr = new XMLHttpRequest();"POST", "json_mysql_data.php", true);
    hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    hr.onreadystatechange = function() {
    if(hr.readyState == 4 && hr.status == 200) {
    var d = JSON.parse(hr.responseText);
    arbitrarybox.innerHTML = d.arbitrary.returntime;
    databox.innerHTML = "";
    for(var o in d){
    databox.innerHTML += +d[o].id;
    databox.innerHTML +=+d[o].name;
    databox.innerHTML += +d[o].pass;
    databox.innerHTML = "requesting…";
    //myTimer = setTimeout('ajax_json_data()',6000);
    <h2>Timed JSON Data Request Random Items Script</h2>
    <div id="databox"></div>
    <div id="arbitrarybox"></div>

  5. Rob Baartwijk
    March 22, 2018 at 20:42

    Nice, but where is connect_db.php?

  6. Chad Pace
    March 22, 2018 at 20:42

    Pronounced "jason" like the name bro

  7. Nambi Jagannathan
    March 22, 2018 at 20:42

    great lessons..explained very well.

    March 22, 2018 at 20:42

    Very useful tutorial.. Thank you. This really helps me working on my thesis.

  9. 44mod
    March 22, 2018 at 20:42

    Great job Adam you are the Poo! 

  10. Peter Floyd
    March 22, 2018 at 20:42

    Excellent tutorial. Worked after the first time (well I missed one bracket due to a typing error). Very straight forward!

  11. M K
    March 22, 2018 at 20:42

    How tables for this example should look like (tables names ect)? help

  12. MonadicBind
    March 22, 2018 at 20:42

    Not working for me. Help! … php doesn't go pass … if (isset($_POST['limit']))

  13. A Estrada
    March 22, 2018 at 20:42

    just what I needed, thanks dude

  14. Dominic Küchler
    March 22, 2018 at 20:42

    Hi Adam, found your tutorial series on my search for ressources for JSON to get started doing some stuff with android apps and getting data from mysql for this.

    The videos are very well done, spoken slowly and good understandable (special when not native english speaking), giving the needed information to each used function at right time and an overview of the co-working of each function with the other.
    They gave me a very good basic overview how to get started with JSON, thank you very much for the time you spend in this videos. Will keep an eye on your websites! Br Dom

  15. TheRoxas13th
    March 22, 2018 at 20:42

    Hmm, what preg_replace do then? ._. I kinda confuse at there.

  16. Noah Nobody
    March 22, 2018 at 20:42

    You can call the data from mysql with php, then pass the array result into php's json_decode() function.

  17. salim ali
    March 22, 2018 at 20:42

    Do you have any tutorial for getting data from mysql database and and display using json ????

  18. Fathur Rochman
    March 22, 2018 at 20:42

    how to get this file doc (PDF)

  19. teilujj
    March 22, 2018 at 20:42

    I owe you a massive thank you! Your tutorials saved me. Got 100% on my assignment thanks to you 🙂

  20. dirtyweasel
    March 22, 2018 at 20:42

    suppose there are no numbers in the limit variable?

  21. Ping Charlton Chen
    March 22, 2018 at 20:42

    Hi Adam,

    I have a problem to view the page I have copied the source codes and put them into the live server to test, it shows nothing but the request… Not sure what else I need to do.I have just copied the part 3 tutorial source code from your youtube site. Any helps would be greatly appreciated!

  22. Billa Raj
    March 22, 2018 at 20:42

    Thanks Adam, Nice video series, Now I have good knowledge on JSON from basic. Thanks once again for your Amazing and excellent videos..

  23. Peacemaker2027
    March 22, 2018 at 20:42

    DON'T FORGET THE GODDAMN FANLOADER!!! good video series!

  24. Virtous
    March 22, 2018 at 20:42

    Hey Adam thanks for the great videos… do you have any tutorials that explain websockets?

  25. mywayjohnson
    March 22, 2018 at 20:42

    How can we show an IMAGE from our DATABASE by the side of each. images can be jpg,JPEG,gif, and all other common image formats

  26. Josh Zoff
    March 22, 2018 at 20:42

    dude i gotta thank you, i knew nothing about web development two weeks ago, now i'm coding in html, css, php, javascript, using jquery and ajax… now json. cant wait till the new web intersect videos come out. send me a msg back if u wanna check what i did with the site so far

  27. Nikolay Mollov
    March 22, 2018 at 20:42

    Adam, can you insert an affiliate component in the new project

  28. 123japanuser
    March 22, 2018 at 20:42

    Salute to you for settling the issue with JSON, Thanks

  29. Ionel Lupu
    March 22, 2018 at 20:42

    please make some socket server programming tutorials (without html5's websockets)

  30. Isaac Price
    March 22, 2018 at 20:42

    Great job mang! This is really sweet.

  31. MrShawnlloyd
    March 22, 2018 at 20:42

    haha, I saw your shortbus images on your desktop… too funny mang

  32. Jay Mee
    March 22, 2018 at 20:42

    GREAT video your a genius can you help me build a buy friend (user) as a pet game called pets (similar to tagged dot com pets game where each user has a value and can be owned by other users. i have a few files but got stuck at how the user is displayed i can add a user that plays pets into the pets database and then got stuck on the link that a user can click to purchase / own a user on the pets game.

  33. Adam Khoury
    March 22, 2018 at 20:42

    Don't use Ajax requests for that. I would not request or check database at intervals less than 10 seconds using Ajax. Look into socket server programming for that. PHP and JavaScript both are capable of socket server engineering. HTML5 also has websockets. Node.js and socketio are Frameworks for socket server programming.

Leave A Comment

You must be logged in to post a comment.