Jump to content

I need a creative solution


phporcaffeine

Recommended Posts

Here is what I need:

I have an application where a user creates a MySQL record based on HTML <form> input. In the from the user selects an option to be reminded about the record at X interval.

I need a creative solution to creating the "popup reminder" I am speaking about.

I could use AJAX for for a 'real-time' effect, but depending on the amount of records it could become a huge SQL call that is done through AJAX which would null the 'real-time' effect and be a huge resource hit.

The other option that comes to mind is just do a query at each page load but that requires the user to first 'do-something' before the reminder popup is checked, which is how the client / server architecture works - I realize that.

The problem is that I 'still have to make it work'.

So, does anyone have an ideas, work-arounds or creative solutions?
Link to comment
Share on other sites

Why would doing it in ajax become nullify the "real time" part of ajax? If the script is returning a huge amount of results, then just use ajax to check and see if there are alerts to view, if there is, then give the user a message, if not, then leave them alone.

Ajax has nothing to do with the actual query...it's merely displaying the results. Your server is doing the query.
Link to comment
Share on other sites

[!--quoteo(post=357164:date=Mar 21 2006, 08:30 PM:name=hitman6003)--][div class=\'quotetop\']QUOTE(hitman6003 @ Mar 21 2006, 08:30 PM) [snapback]357164[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Why would doing it in ajax become nullify the "real time" part of ajax? If the script is returning a huge amount of results, then just use ajax to check and see if there are alerts to view, if there is, then give the user a message, if not, then leave them alone.

Ajax has nothing to do with the actual query...it's merely displaying the results. Your server is doing the query.
[/quote]


Let me define further -

I realize that AJAX is nothing more than a handful of JavaScript and a pinch of XML, it's not the AJAX that I am worried about - AJAX is just the conduit.

Here is what I am worried about:

8000 + MySQL records

$sql = mysql_query("SELECT * FROM tbl_name WHERE reminder = ' pre determined interval '");

while ($row = mysql_fetch_array($SQL)) {

$results_array[] = $row['id'];

}

Now, if I have AJAX run when the onFocus, onLoad ....etc event fires and then just continue to run (in order to be truly accurate it would have to continually run because as the seconds tick by on the server an "interval" for one of the records may be reached) PHP would be "asked" to re-run that query - over & over & over & over & over, which is where the resource hit comes in to play.

PHP won't "remember" the query results for the next time that the xmlhttpRequest object calls the script so the only option would be for PHP to re-run the query when it is called again by the xmlhttpRequest object.

When I say "continually run" I mean that the xmlhttpRequest object would have to call PHP once every 1-2 seconds. So as long as the user(s) were camped on the page that has AJAX - it would look like a non-stop MySQL call to the server, then multiply that effect * X users and your in for some real issues.

If the databased ever reached the point where the query took more than 1-2 seconds to run then it would be out of sync with the time it took the xmlhttpRequest object to call and thus the "reminder" of 15 minutes after 2pm might be 17 or 18 minutes after 2pm

If I was only talking about 1-2 records and only 1-2 concurrent connections it wouldn't be an issue.

I am trying to achieve the effect of an asynchronous "reminder", similar to the effect of a "Calendar/Event" alarm and it may be that this just isn't possible.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.