Тёмный
No video :(

Get data from database using AJAX, Javascript, PHP, MySQL 

Adnan Afzal
Подписаться 8 тыс.
Просмотров 152 тыс.
50% 1

Get data from database using AJAX, Javascript, PHP, MySQL
Source files:
adnan-tech.com...

Опубликовано:

 

25 июн 2017

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 161   
@arminharper510
@arminharper510 4 года назад
finally a tut on AJAX+mysql+vanilla JS. everyone is teaching this using jQuery, but i don't need to use the entire library just for it's AJAX methods. i'm trying to build a live chat app and am going to try it using the info here. THANK YOU.
@AdnanAfzal565
@AdnanAfzal565 4 года назад
You're welcome. Good luck with your live chat app. I have already created a tutorial for live chat app, below is the link: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Ozrm_xftcjQ.html
@amitgahatraj4
@amitgahatraj4 2 года назад
This is by far on of the best tutorial I've ever seen. Short but includes each and every possible information. Thanks a lot.
@AdnanAfzal565
@AdnanAfzal565 2 года назад
You are welcome. And thanks.
@seilasan4894
@seilasan4894 3 года назад
you are saving me now. thank you from Phnom Penh Cambodia. :)
@JESR-og2xc
@JESR-og2xc 3 года назад
After hours of searching and nearly giving up, you showed me how it to do it. Thanks a lot, this video was very helpful.
@AdnanAfzal565
@AdnanAfzal565 3 года назад
You are welcome. Glad it helped.
@zichunzhang6121
@zichunzhang6121 4 года назад
Dude, i have no idea what to say. It's just like magic. I am now a fan of ajax now. what a beautiful way to interact with the database! Ty so much!
@AdnanAfzal565
@AdnanAfzal565 4 года назад
You're welcome.
@jumpman23nith
@jumpman23nith 2 года назад
This is the best AJAX tutorial by far. Thank you for this.
@AdnanAfzal565
@AdnanAfzal565 2 года назад
You are welcome.
@raphaelsefakoradinkrah6533
@raphaelsefakoradinkrah6533 4 года назад
This tutorial actually saved my Ass, thank you Adnan Afzal
@AdnanAfzal565
@AdnanAfzal565 4 года назад
:) you're welcome.
@MovieHeretic
@MovieHeretic 3 года назад
Absolutely brilliant, been looking for an ajax tutorial that handles arrays and finally someone goes a step beyond the normal simple data examples. New subscriber bro.
@AdnanAfzal565
@AdnanAfzal565 3 года назад
Thank you very much. Glad it helped.
@alexgraham1199
@alexgraham1199 4 года назад
Thanks so much for this. I needed a really simple and pragmatic approach to get data and this simple solution came at the end of 5 hours of faffing.
@eliasbinde2629
@eliasbinde2629 4 года назад
Thank you! Straight to the point and easy to follow.
@AdnanAfzal565
@AdnanAfzal565 4 года назад
You're welcome.
@timow6929
@timow6929 5 лет назад
THANK YOU! The only easy to understand and to use tutorial out in this trash internet
@AdnanAfzal565
@AdnanAfzal565 5 лет назад
You're welcome. Glad to help.
@robinr2336
@robinr2336 5 лет назад
👍 This was good! But for a noob to PHP, audio explanations would have made this perfect. Even though a book is silent, one can still read code explanations and details.
@AdnanAfzal565
@AdnanAfzal565 5 лет назад
Yes, audio will be added soon.
@relife476
@relife476 4 года назад
@@AdnanAfzal565 Please, and thanks you.
@pankajclasses9569
@pankajclasses9569 4 года назад
Excellent.....Made my life easier
@shontzu
@shontzu 3 года назад
This is so understandable. Had to send this to my peers...! thank you
@AdnanAfzal565
@AdnanAfzal565 3 года назад
Thank you.
@oantoniolima
@oantoniolima 3 года назад
Hello there, can you help me? I want to use that "data" array in an if to check is a certain column is set to 0 or to 1, i defined var data = {} outside of the function but It's not working, I'm doing an if (data["article_flag(the column)"] == 1) { function to execute }
@AdnanAfzal565
@AdnanAfzal565 3 года назад
In javascript, you need to use data.article_flag, dot.
@joydeepbhattacharjee5305
@joydeepbhattacharjee5305 4 года назад
awesome tutorial thank u sir
@ryuta4754
@ryuta4754 4 года назад
That's it I've been looking for !! Thank you !!
@AdnanAfzal565
@AdnanAfzal565 4 года назад
You're welcome.
@jesusromero2046
@jesusromero2046 4 года назад
Thanks dude, not exactly what I was looking for but shed a enough light to resolve my problem...btw after a lot of hours surffing on Internet
@AdnanAfzal565
@AdnanAfzal565 4 года назад
Thanks.
@rehmansarwar8392
@rehmansarwar8392 4 года назад
great Effort and magnificent method.
@ralitsoft8204
@ralitsoft8204 4 года назад
Great Video Get helpful
@AdnanAfzal565
@AdnanAfzal565 4 года назад
Glad it helped
@DineshNairMumbai
@DineshNairMumbai 5 лет назад
wonderful and different from the way we normally do.
@wrzq
@wrzq 5 лет назад
Brilliant, thank you Adnan for this tutorial.
@mdnasimralitsoft9488
@mdnasimralitsoft9488 4 года назад
Very nice activity .....
@AdnanAfzal565
@AdnanAfzal565 4 года назад
Thank you so much 🙂
@yannik8271
@yannik8271 2 года назад
Bro this was so helpful. Thank you man!
@AdnanAfzal565
@AdnanAfzal565 2 года назад
You are welcome.
@leecravens1184
@leecravens1184 4 года назад
This is a new language for me, as I have been writing in pure PHP for years. I was able to follow this video and retrieve all rows from my db where a column had a specific value. The problem is, that when I add a new row in the db that has the same value at from my WHERE clause, the new row never shows up. I still have to force a refresh (F5). This is the same scenerio in multiple web browsers, so I'm thinking it is in the code (probably my fault, I am sure!) Any thoughts on why this would not show the new rows? The table I am querying will be INSERT only, no UPDATE or DELETE, to maintain data integrity. I just edited one of the rows directly from the database (not yet live, it is in the testing phase) to see if the changes would show on existing rows that are being displayed on my test page, and they don't show updates either! What am I missing?!?
@AdnanAfzal565
@AdnanAfzal565 4 года назад
You need to insert the record using AJAX. You can follow this: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-UDmAlpYVwbU.html When the response is received from this AJAX, you can send ajax the AJAX to get all records.
@RadiantX917
@RadiantX917 2 года назад
If you modify the table in background does it reflect the change without loading of page ?
@AdnanAfzal565
@AdnanAfzal565 2 года назад
No, for realtime update, you need to check our Socket IO tutorial: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-56_k1botx9M.html
@christofermunoz5564
@christofermunoz5564 4 года назад
I had to change mysqli_fetch_assoc to mysqli_fetch_array in the .php file and it worked, thx
@AdnanAfzal565
@AdnanAfzal565 4 года назад
You're welcome.
@neetpg9035
@neetpg9035 4 года назад
You are awesome bro, thank you so much
@AdnanAfzal565
@AdnanAfzal565 4 года назад
Happy to help
@beticohernandez8039
@beticohernandez8039 6 лет назад
Hello, if the file of the array I have it in a hostin I would read the data tabien, that list can show it in list like jquery mobile? Thank you.
@AdnanAfzal565
@AdnanAfzal565 6 лет назад
Yes, you need to call AJAX in order to do that.
@vishnus2567
@vishnus2567 4 года назад
I added a Button. So that the result is displayed only after pressing the button. But the problem is that the result are displayed multiple times on button press. How to clear this?
@AdnanAfzal565
@AdnanAfzal565 4 года назад
Check if the function is being called multiple times.
@manojjangir1154
@manojjangir1154 5 лет назад
nice explanation
@AdnanAfzal565
@AdnanAfzal565 5 лет назад
Thanks. Keep sharing please.
@rijovg
@rijovg 6 лет назад
how is the where condition using passing parameter ?
@arminaebrahimsulaiman738
@arminaebrahimsulaiman738 4 года назад
Excellent!!!
@AdnanAfzal565
@AdnanAfzal565 4 года назад
Many thanks!
@judanetwork
@judanetwork 6 лет назад
hi nice video, so the code to read the employees table is $result = mysql_query($conn, "SELECT * FROM employees"); right?
@AdnanAfzal565
@AdnanAfzal565 6 лет назад
Yes. That is right.
@DevangBhattDev
@DevangBhattDev 3 года назад
How to get any specific lines of data ? If I want to display data for only 1 Employee ??
@AdnanAfzal565
@AdnanAfzal565 3 года назад
You can add a WHERE clause in the query, for example: SELECT * FROM users WHERE id = 3;
@imtiyazahmad617
@imtiyazahmad617 6 лет назад
thank you so much really helpful superb only sound is required
@AdnanAfzal565
@AdnanAfzal565 6 лет назад
Thank you. Yes, sound will be added in future tutorials.
@kuodong
@kuodong 5 лет назад
Hi, may I ask why convert array into JSON AND again convert JSON back to array. ??
@AdnanAfzal565
@AdnanAfzal565 5 лет назад
Hi. Because if you have a lot of data then it would be difficult to send as PHP objects. So we send them as JSON string. Now data will be sent as string not objects.
@josellecallora08
@josellecallora08 Год назад
Thanks for this!! Beeen searching for pure js live data.. anyway, is it possible for me to put a button at the end of the table? hope you could recommend me a video that includes an action at the end of the table where the user could delete or edit the column.. thank you!
@AdnanAfzal565
@AdnanAfzal565 Год назад
Sure. You can follow this: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-qYbkQpSI9_o.html
@josellecallora08
@josellecallora08 Год назад
@@AdnanAfzal565 wow, you are active until now. thank you! btw, i liked and subscribed.
@AdnanAfzal565
@AdnanAfzal565 Год назад
Thank you.
@rajeshmaurya681
@rajeshmaurya681 6 лет назад
Thank you so much really helpful superb....
@AdnanAfzal565
@AdnanAfzal565 6 лет назад
my pleasure
@futuretechx5754
@futuretechx5754 5 лет назад
Searching for days, and found this. Absolutely amazing. Best is so many other sites don't have code download, thanks for that. The mysqlsampledatabase.sql to create the database couldn't be better. Thank you so much for this, from a beginner who has learnt so much from you.
@AdnanAfzal565
@AdnanAfzal565 5 лет назад
Welcome. Keep sharing please.
@HongKong1842
@HongKong1842 3 года назад
what is the benefit of bringing in Json, while the record row can actually be printed directly?
@AdnanAfzal565
@AdnanAfzal565 3 года назад
If you directly print the data using PHP, then it will increase your page load time. Also, if there is any error in PHP, then it will crash your page.
@HongKong1842
@HongKong1842 3 года назад
@@AdnanAfzal565 Thank you. I know only php mysql. If I add this feature, in average how much time it saves for a general page with perhaps 20 fields to be printed?
@AdnanAfzal565
@AdnanAfzal565 3 года назад
It depends on server. May be 1-2 seconds.
@HongKong1842
@HongKong1842 3 года назад
@@AdnanAfzal565 how come php echo will crash more easily?
@AdnanAfzal565
@AdnanAfzal565 3 года назад
Simple code will work fine. But if you have a very complex sql query, are performing certain operations on arrays and objects. Or using 3rd party library, then it is a possibility.
@mygrof
@mygrof Год назад
In my case it stores html into json, is it bcs I am using Smarty?
@AdnanAfzal565
@AdnanAfzal565 Год назад
Yes. Smarty template might be doing the conversion.
@georgemendle5587
@georgemendle5587 3 года назад
Intro kamal
@AdnanAfzal565
@AdnanAfzal565 3 года назад
Thanks. Let me know if you want to have one with your name and logo.
@adrianoldchannel2494
@adrianoldchannel2494 6 лет назад
Lovely video. Click
@ReubenMRU
@ReubenMRU 4 года назад
Hello, Thanks a lot for this... Doing just that i seem to be limited to retrieving only 150 rows... if i try to retrieve more, i get an empty string instead... I'm on Xampp/mariaDB - I tried to set the post_max_size to 0 in the php.ini file, to no avail... even restarted the server afterwards... still limited... any thoughts?
@AdnanAfzal565
@AdnanAfzal565 4 года назад
Check if there is any limit in query. Or in loop.
@ReubenMRU
@ReubenMRU 4 года назад
@@AdnanAfzal565 Thanks for getting back to me so quickly - turns out it was accents.. the 151st row had an accent and because of that the query returned an empty set... been trying to fix this but none of the solutions i found online are helping so far :/
@AdnanAfzal565
@AdnanAfzal565 4 года назад
@@ReubenMRU Try following before running the query: mysqli_set_charset($connection, "utf8");
@ReubenMRU
@ReubenMRU 4 года назад
@@AdnanAfzal565 thanks, still doesn't work unfortunately :/ Getting this: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data Also converted my DB, Table and column to utf8mb4 - to try and fix this... doesn't seem to work at all
@ReubenMRU
@ReubenMRU 4 года назад
@@AdnanAfzal565 Thanks I got it to work - not sure what exactly did it though, lol...
@shivamgarg8398
@shivamgarg8398 3 года назад
love you mannn
@FranklinmsZa
@FranklinmsZa 5 лет назад
Well done, Thank you for this video
@AdnanAfzal565
@AdnanAfzal565 5 лет назад
Thanks. Glad to help.
@Gustablealves
@Gustablealves 6 лет назад
Nice tutorial
@AdnanAfzal565
@AdnanAfzal565 6 лет назад
Thanks.
@hannesmann1000
@hannesmann1000 5 лет назад
Good video I subscribred!
@AdnanAfzal565
@AdnanAfzal565 5 лет назад
Thanks.
@chapulinazulado7717
@chapulinazulado7717 3 года назад
porque nao usou o setInterval(function(){ajax();}, 1000); ?
@AdnanAfzal565
@AdnanAfzal565 3 года назад
It will send the request to server every second. You can use Node JS to get realtime data. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-sMPayYZFodE.html
@snjvthakur24
@snjvthakur24 4 года назад
can i use it for fetch data from wordpress database and use data in javascript
@AdnanAfzal565
@AdnanAfzal565 4 года назад
Not using this tutorial. But you can follow this: premium.wpmudev.org/blog/using-ajax-with-wordpress/
@Cheffak
@Cheffak 6 лет назад
Is that a Python programmer in your intro? :O
@AdnanAfzal565
@AdnanAfzal565 6 лет назад
No :)
@beticohernandez8039
@beticohernandez8039 6 лет назад
With the tuturial code you can do that
@shahmasumzaman4647
@shahmasumzaman4647 5 лет назад
Thanks U Helped me
@AdnanAfzal565
@AdnanAfzal565 5 лет назад
Great
@simaopacheco4529
@simaopacheco4529 4 года назад
is this save to use? since javascript is a cliente side? which can be "easily" manipulated by client?
@AdnanAfzal565
@AdnanAfzal565 4 года назад
Yes, all the database credentials are at server side. So no worries.
@simaopacheco4529
@simaopacheco4529 4 года назад
@@AdnanAfzal565 ok, thnx for the tutorial, consider talking when writting it helps us to understand the code better instead of just copying from you
@AdnanAfzal565
@AdnanAfzal565 4 года назад
@@simaopacheco4529 Okay, thank you. Next time I will keep that in mind.
@markystudio14
@markystudio14 3 года назад
Thank you dude 😊 but I have a problem why my data is duplicated ? 1 user 1 user 2 user2 2 user2 Where is my problem ?
@markystudio14
@markystudio14 3 года назад
I figured out that the problem is In array_push statement. Array_push($data, $row); I tried to delete the $row var in array_push statement and the result is not duplicated. Inshort the problem is finally solved. But still I don't know the conflict after I removed this. But I still wonder why my data is duplicated output, while in your case is not? I didn't understand yet what is the main purpose of array_push.
@AdnanAfzal565
@AdnanAfzal565 3 года назад
@@markystudio14 array_push insert the data in array. Check if you are receiving duplicate data from database. May be the problem is not in PHP code, but in MySQL query.
@desirocker9099
@desirocker9099 5 лет назад
Can you please make a video for fetching only when there is new data using long polling method, because as I have heard, this method would put a strain on the server.
@AdnanAfzal565
@AdnanAfzal565 5 лет назад
Yes, it requires Socket IO, I will do that tutorial and will let you know.
@desirocker9099
@desirocker9099 5 лет назад
@@AdnanAfzal565 Can we implement socket.io with php and apache back end?
@AdnanAfzal565
@AdnanAfzal565 5 лет назад
@@desirocker9099 Yes, you can use Ratchet PHP API for sockets.
@kisme01
@kisme01 5 лет назад
very hard to find. thank you
@AdnanAfzal565
@AdnanAfzal565 5 лет назад
Welcome. Please keep sharing.
@jasonking1284
@jasonking1284 5 лет назад
Hmmm..... That could be achieved in pure PHP in a couple of lines.... I suppose if you have an adfested page where you want to only update the 3 square inches of actual information of value without loading all the ads again, JavaScript is useful. Still.. at least a video showing Ajax WITHOUT using JQuery. Good.
@user-sx3ly9bn2g
@user-sx3ly9bn2g 4 года назад
thank you for your video!
@AdnanAfzal565
@AdnanAfzal565 4 года назад
Glad it was helpful!
@albertolizarraga98
@albertolizarraga98 4 года назад
Thanks!
@AdnanAfzal565
@AdnanAfzal565 4 года назад
You're welcome.
@Rahulsharma-el6fs
@Rahulsharma-el6fs Год назад
Thanks
@AdnanAfzal565
@AdnanAfzal565 Год назад
Welcome
@renecabuhan1675
@renecabuhan1675 2 года назад
Thanks 😊
@AdnanAfzal565
@AdnanAfzal565 2 года назад
You are welcome.
@hasagine3479
@hasagine3479 5 лет назад
thanks bro
@AdnanAfzal565
@AdnanAfzal565 5 лет назад
Welcome. Keep sharing.
@protip2950
@protip2950 4 года назад
The best
@AdnanAfzal565
@AdnanAfzal565 4 года назад
Thanks.
@martins.8349
@martins.8349 3 года назад
idk i had same code and it just returned myentire html page
@AdnanAfzal565
@AdnanAfzal565 3 года назад
You must be doing: document.write()
@gyurmesherpa3965
@gyurmesherpa3965 5 лет назад
Wow...
@AdnanAfzal565
@AdnanAfzal565 5 лет назад
:)
@DineshNairMumbai
@DineshNairMumbai 5 лет назад
pls send a link if available where we can write into a table using a similar ajax script
@AdnanAfzal565
@AdnanAfzal565 5 лет назад
This is already displaying in format.
@DineshNairMumbai
@DineshNairMumbai 5 лет назад
@@AdnanAfzal565 Sorry... not format but database=> table
@AdnanAfzal565
@AdnanAfzal565 5 лет назад
@@DineshNairMumbai Okay. That will be just designing thing.
@anshitamakode6097
@anshitamakode6097 4 года назад
Not worked...actually it is not showing array in console
@AdnanAfzal565
@AdnanAfzal565 4 года назад
It means there is an error on server side. Double check the variables and make sure database connection is right.
@arupduttabappy3284
@arupduttabappy3284 3 года назад
👍💜
@AdnanAfzal565
@AdnanAfzal565 3 года назад
Thanks.
@riteshpandey694
@riteshpandey694 4 года назад
liked for Welcome scene
@CJ_YT
@CJ_YT 3 года назад
Is it refeshing data without refeshing website?
@AdnanAfzal565
@AdnanAfzal565 3 года назад
Yes.
@CJ_YT
@CJ_YT 3 года назад
@@AdnanAfzal565 I have to use timer or something like this to refresh data on website ? When I am changing data in database now, website displays the same data like before (are unchanged). When I refresh website only by F5 - data is changing. What's wrong with me ?
@AdnanAfzal565
@AdnanAfzal565 3 года назад
You can follow this: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-sMPayYZFodE.html
@samirpatel7141
@samirpatel7141 5 лет назад
Can i get the source code of this please
@AdnanAfzal565
@AdnanAfzal565 5 лет назад
Yes, will upload and send you link soon.
@AdnanAfzal565
@AdnanAfzal565 4 года назад
Sorry for very late reply, but here is the source code: adnan-tech.com/tutorial/get-data-from-database-using-ajax-javascript-php-mysql
@armuc6941
@armuc6941 3 года назад
Bizarre !!
@danzzeidan4412
@danzzeidan4412 Год назад
next time please link your file :( but thanks anyways
@AdnanAfzal565
@AdnanAfzal565 Год назад
You are welcome. The link to files is already mentioned in the description of this video.
Далее
JSON and AJAX Tutorial: With Real Examples
40:45
Просмотров 1,8 млн
Save HTML Form Data to a MySQL Database using PHP
24:38
Learn JSON in 10 Minutes
12:00
Просмотров 3,1 млн
Brutally honest advice for new .NET Web Developers
7:19
Submit form with ajax and store data into database
15:54