I have a site (php) with a text editor that I want to be saved automatically every few minutes (on mysql) and I wanted to consult with you about this.
(You may know this behavior from the Google Docs platform.)
Won't it kill my DB if I'll call it again and again?
Is their a known approach for this type of feature?
Does it matter if I save every minute or every type that the user is doing?
Any tips that can help me start with this feature?
It depends on your server and the amount of data saved to mysql, tell us more why do you want to save text editor data to database, im pretty sure theres a better way to do this.
If you want to save data for users, you should use local storage, you can do it using JQuery plugins:
Ex:
http://www.jstorage.info/
Related
I am developing a website using HTML5, js, php,... I have a doubt and I don't know if can be solved.
I have a settings tabs, where I select some alerts from values received from thingspeak. For example using a temperature sensor, I select from 10 to 20 ÂșC the alert and then depends on the value received it will be shown a notification. I have not developed this part yet, but I want to know if would be possible to save that. I have a DB for the user details, but I want to save this without saving this into a DB.
The main problem of this I think is when you close the web browser and the slider values will be restored when you open again. How can I save those alert settings? Should the best option to store in a db? How can I do this?, because can have more than 10 alerts, and I don't know how to store this in a db
Cookies would do a pretty nice job especially if you can handle their dimensional form but you have to put in mind that if you personally want these data/information in the nearest/far future then you have no choice but to stick with the conventional DB.
I am building a weather station that will update the weather in "real-time" to a MySQL Database. To give the feel of "real-time" without taking up a ton of space on my MySQL server, I have my weather station updating a single cell in the MySQL database every few seconds. I would like to set up a way for a website to view this change in realtime without refreshing the page. I have tried researching a lot, but I can't quite find what I am looking for (at least with more of an explanation into the JQuery and how it works). Most answers have partial as people have a lot more experience.
I have a little experience with PHP and MySQL (I have just started learning a couple of months ago). This project is more of a way to learn JQuery and AJAX (along with PHP and MySQL). Frankly, I don't know a ton as I am just starting into programming.
If I could get a bit more of an explanation into how the JQuery works and what files I need to be placing the information in, that would be great (a lot of other similar answers had a separate "server" file and a "client" file in PHP. Do I really need that?).
I just don't know where to begin or what to put in what files. Maybe I need a tutorial? Thanks.
I think what you are looking for is "Push Technology". But, as a beginner like me, I would introduce you to try out "long pulling". Although is not the best method, you can learn how real-time update works.
I suggest you create a normal working AJAX, then use the code below to repeatedly call for updates from the server.
jQuery(document).ready(function () {
interval = setInterval("checkNewUpdate()",4000); //Set interval for accident checking ajax
}
This function basically retrieves information from the database every 4seconds. This method is not so efficient, but I hope would help you to kick start in push technology.
Visit How do I implement basic "Long Polling"? for more information.
I suggest you to create a function to check database status, something like count row in the database or something else like that... the return must be simple a data like number , true or false (not a long data) with interval .. and when it change the fetch function will run
I'm running a server and website for an online game.
I need to pull information from the mySQL database containing player names and messages and display it on our website.
I managed to do that with a php script which directly pulls the info from the MySQL database whenever someone opens the page.
However, this puts unnecessary load on the server.
I need to achieve so that the function pulls the data only at certain intervals, for example, every hour.
I have no idea how to do this and what to even look for in terms of functions.
Could anyone show me the right direction?
If you're worried about the load being placed on the call being made every time the user opens up the site, perhaps first you should look into caching. Something like APC or memcached, that way there isn't an actual DB lookup, it just returns the same data that it grabbed last time You just set the period that you want the cache to hold the data so that in time it will grab a fresh copy, in your case this would be an hour.
There's a bunch of questions on APC, memcached etc on stack overflow that should be able to help you out, e.g., The best way of PHP Caching
I've been looking for an easy way to track my current session variables on my desktop in order to have an eye on them.
My website uses Joomla and session variables are stored in MySQL by PHP.
What I'd like to achieve is a 'widget' or 'snippet' which could show on my Windows 7 desktop current session variables, and how they change during a visit on the website.
In fact the session state is stored in a table like:
session_id varchar(32)
data varchar(20480)
userid int(11)
So let say one solution could be retrieving first two columns by my userid with a SQL query and parsing 'data' column, which is in JSON format, into an 'snippet' object.
I don't know how to write widget/snippets and I don't expect anybody to write me one, I just wonder if such thing exist to make my developing easier.
Well, if you want to hack together something, I've got a couple of crude suggestions.
Write a simple SQL query ordered by date, throw in some HTML and add javascript to auto refresh the page, say every 30 seconds. Now you just need a tab open to monitor your sessions.
The same thing as above but instead of HTML, output XML in the feed format. Then use any feed reader software which usually has desktop widgets and alerts etc.
Good luck!
Well, it's been long time since I asked this question. So far, the best option I've found was PHP Quick Profiler tunned a bit up for Joomla Framework. Soon, I gonna post a tutorial how to implement this for Joomla. Should anybody want to hurry me up do not hesitate :)
I have table called playlist, and I display those details using display_playlist.php file.
screen shot of display_playlist.php:
Every time user clicks the 'up' or 'down' button to arrange the song order, I just update the table.But I feel updating DB very often is not recommended, so Is there any efficient way to accomplish this task.
I am still a newbie to AJAX, so if AJAX is the only way to do it, can you please explain it in detail.thank you in advance.
In relative terms, yes, hitting the database is an expensive operation. However, if the playlist state is meant to be persistent then you have to hit the database at some point, it's just a question of when/how often.
One simple optimization you might try is instead of sending each change the user makes to the server right away, allow them to make however many changes they want (using some client-side javascript to keep the UI in the correct state) and provide a "Save Playlist" button that they can press to submit all of their changes to the server at once. That will reduce database hits, and also the number of round-trips made to the server (in terms of what a user experiences, a round-trip to the server is far more expensive than a database hit).
More broadly though, you shouldn't get hung up over hypothetical performance concerns. Is your application too slow to handle its current load (and if so, have you done any profiling to verify that it is indeed this database query that is causing the issue)? If not, then you don't need to worry too much about changing it just yet.
You can have a save button, so instead of updating on each move there will only be one update where you update every row at one time. This also lets you have a cancel button for people to refresh the way it was.
You can do it so users can change locally all they wish; defer writing the final result to the database until they choose to move on from the page.
if you really want to avoid updating the database, you can try some JavaScript based MP3players , which allow you to pass the path to *.mp3 files.
Then I suggest you to use Jquery UI - Sortable
and use it to update the songs list to the flash player ..