SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict Philip Toews's Avatar
    Join Date
    Dec 2001
    Location
    Kuala Belait, Brunei
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    refresh a page problem

    I am trying to get a page to refresh after a certain number of email newsletters are sent from a PHP script working from a MySQL DB.

    Here's the part of the script that sends the mail:

    PHP Code:
     ini_set('max_execution_time''0'); // sets timeout to never

    $subscribers mysql_query("SELECT email, newsletter_format FROM newsletter WHERE validation = 1");
    if (!
    $subscribers) {
      echo(
    "<p>Error retrieving subscriber list from database!<br />".
           
    "Error: " mysql_error() . "</p>");
      exit();
    }

    while (
    $subscriber mysql_fetch_array($subscribers)) {
        
    $to htmlspecialchars($subscriber['email']);
        
    $newsletter_format htmlspecialchars($subscriber['newsletter_format']);
        if (
    $newsletter_format == 'html') {
            
    mail($to$subject$htmlmessage$htmlheader);
            echo 
    "<p>HTML Newsletter delivered to: $to<br></p> \n";
            
    $htmlsent++;
        } elseif (
    $newsletter_format == 'text') {
            
    mail($to$subject$textmessage$textheader);
            echo 
    "<p>Text Newsletter delivered to: $to<br></p> \n";
            
    $textsent++;
        }

    I want to refresh the page so that I can send a couple of variables to the MySQL query that will select blocks of email addresses in order to send the newsletters out in blocks of 50 or so. The new query I want to rewrite should look something like this:

    PHP Code:
     $subscribers mysql_query("SELECT email, newsletter_format FROM newsletter WHERE validation = 1 LIMIT $startnum,$perpage"); 
    So I need javascript that I can place at the end of the first code snippet above that will reload the page with the variables attached...I KNOW ZERO about javascript...can anyone please help?
    Philip Toews Professional esl Educator and ASP.NET wannabe

    http://www.philiptoews.com
    philip@philiptoews.com

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Birmingham, UK
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the script to reload a page in javascript is

    <Script language="JavaScript">
    function reload(){
    //reloads every minute
    var time = 10000
    window.location.reload
    setTimout("reload()",time)
    }
    </Script>

    the only problem is you cant attatch variables to javascript because it is client side...only thing i can think of doing is putting the variables in a hidden text feild and requestiing them when the page is loaded again...something along those lines.

    how come you have to reload the page anyway? how come you couldnt just have a for loop in it?

  3. #3
    SitePoint Addict Philip Toews's Avatar
    Join Date
    Dec 2001
    Location
    Kuala Belait, Brunei
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I want to track progess of mail out

    Thanks for the reply. I want to be able to track the progress of the mail out. Thanks for the heads up that javascript can't pass variables.

    Can it pass variables as part of a query string?

    p
    Philip Toews Professional esl Educator and ASP.NET wannabe

    http://www.philiptoews.com
    philip@philiptoews.com

  4. #4
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please keep all comments to do with this one in this thread: http://sitepointforums.com/showthrea...threadid=51390

    Thanks.
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •