dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Update?

  1. #1
    Join Date
    Nov 2007
    Posts
    3

    Update?

    well heres my issue I have a mysql query with a while statement, so it prints all the users in a db and I have a popup to add/edit a user. And when the popup closes u have to refresh the page to have it show the updates. Is there a way I can have it refresh just the div, or even just the sql every x seconds?

    I have a switch statement for $_GET['page'] so the refresh cant use GET otherwise it shows the default.

    How will I go about doing this?

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Welcome to DevX

    You could put your code in a loop that continues to execute as long as the page is loaded.

  3. #3
    Join Date
    Nov 2007
    Posts
    3
    Thanks!

    I was thinking of using ajax, but I am not really famailer with js/ajax. I also would not want it to be a loop, I include the page currently using include(), and I want to stay away from frames. Can anyone write up a small script or help? Thanks in advance.

  4. #4
    Join Date
    Nov 2007
    Posts
    3

    Ajax Update

    I am using mootools and greybox.
    Code:
    GreyBox: http://orangoo.com/labs/GreyBox/
    Mootools: http://www.mootools.net/
    Greybox Code:

    Code:
    http://pastebin.com/m642b1fa8
    Ajax Update Code:

    Code:
    window.addEvent('domready', function(){
    			var url = 'incs/files.inc.php?p=admin_users';
    
    			// refresh every 5 seconds
    			var timer = 5;
    			// periodical and dummy variables for later use
    			var periodical, dummy;
    			var start = $('start'), stop = $('stop'), up_users = $('up_users_res');
    
    			/* our ajax istance */
    			var ajax = new Ajax(url, {
    				update: up_users,
    				method: 'get',
    			});
    
    			/* our refresh function: it sets a dummy to prevent
    			   caching of php and add the loader class */
    			var refresh = (function() {
    				// dummy to prevent caching of php
    				dummy = $time() + $random(0, 100);
    				// we add out fancy spinner
    				up_users.empty().addClass('ajax-loading');
    				// requests of our php plus dummy as query
    				ajax.request(dummy);
    			});
    
    			// start and stop click events
                window.addEvent('domready', function() {
            	// the periodical starts here, the * 1000 is because milliseconds required
            	periodical = refresh.periodical(timer * 1000, this);
    
            	// this is the first only request, later on will be only the periodical and refresh
            	// that do the request. If we don't do this way, we have to wait for 4 seconds before
            	// the first request.
            	ajax.request($time());
                });
    		});
    How do I make it, so when the user either closes the popup, or submits the form, it updates, instead of every 5 seconds.
    Help?

  5. #5
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Separate threads merged

Similar Threads

  1. Update 2 tables in a single update query
    By Nomi in forum Database
    Replies: 2
    Last Post: 01-11-2007, 02:24 PM
  2. Replies: 0
    Last Post: 06-04-2002, 10:13 AM
  3. update query
    By an in forum Database
    Replies: 0
    Last Post: 05-08-2002, 01:12 PM
  4. Replies: 0
    Last Post: 05-07-2002, 08:34 PM
  5. Urgent!!! ADO Update conflict
    By Chillu in forum VB Classic
    Replies: 0
    Last Post: 07-14-2000, 12:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center