loading

In my first Instructable "Getting Arduino data to a web page" I talked about refreshing the data by using the Meta command to refresh the MySQL data content. The problem with this is that it refreshes the entire page and could possibly interfere with other scripts as well. Not to mention the annoying blinking. So I have made a couple of improvements that might just make things work together a little more smoothly. This Instructable uses the same files as the original project with the exception of adding two "php" files "clock.php" and "update.php" as well as modifying the "index.htm" file. The files can be downloaded at the bottom of the page. To view the web page updating watch the video file below.

Step 1: How to Refresh the Data!

I began with the problem of how to update information from the MySQL database first. After some research, trial and error I determined that the best way to do this is put my PHP scripts in a separate PHP document then update the document with the meta refresh command. This continuously updated the data! I then found a jQuery script that would refresh anything within a "div or span" html tag. I then put the two together and "wala" data refreshing without refreshing the entire page and content!!

The Script above is from the Index file and is used to update the MySQL data without refreshing the whole page. The "update.php" file is used here, but you can replace the files and the "id's" within the div or span tags with your own names. Once again this only updates the HTML file and not the PHP file.

Step 2: Another Method for Bringing Refreshed Data Into the Web Page!

Here is another method of bringing a php document that needed to be refreshed without refreshing the entire web page. This method usually requires a "onLoad" statement within the body tag ie.. "<body onLoad="goforit()">" but not always. The updating of the script is done in a external "PHP" file just like the first method and then brought into the " HTML" document.

Thanks for viewing and I hope you find this useful!

<p>Hello <a href="https://www.instructables.com/member/dkschottt/" rel="nofollow">dkschottt</a>,</p><p>Thank you for your instructables!</p><p>I am new in mySQL world, I've just copy and paste your code to WAMP server and got error since now all mysql_xxx syntaxes have been changed to mysqli_xxx.</p><p>Could you please tell me what version php do you use? Thank you</p>
Sorry for the delay!! I am using PHP version 5.5.12

About This Instructable

4,344views

11favorites

License:

More by dkschottt:Refreshing MySql data within a Web Page Getting Arduino data to a web Page 
Add instructable to: