SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict kivison's Avatar
    Join Date
    Dec 2004
    Location
    Whitley Bay, Tyne & Wear, UK
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Email counter Not working

    Hi Friends!

    I have been working on a database that will create an email link for outlook using a mailto: command in HTML

    The code i have up to now is:-
    PHP Code:

    $count=1;
    ?>
    <font size="-4">
    <?php
    $clientquery 
    = @mysql_query($select $from $where $bywhat);
    if (!
    $clientquery) {
      
      exit(
    '<p>Error retrieving email addresses from database!<br />'.
          
    'Error: ' mysql_error() . '</p>');
    }
    echo 
    "<a href='Mailto:me@testemailaddress.co.uk?subject=$message&bcc=";
    while (
    $count 10) {
                    while (
    $clients mysql_fetch_array($clientquery)) {
                    
    $LeadIDNumber $clients['LeadIDNumber'];
                    
    $FirstName =$clients['FirstName'];
                    
    $LastName =$clients['LastName'];
                    
    $EmailName =$clients['EmailName'];
                    echo 
    "$EmailName;";
                    
    $count++;
                    }
        }
        
        echo 
    "'>Send mail</a>"
    Outlook has an issue that you can only send a maximum of 100 BCC's out at at time. I need to use outlook because the email to the clients is in HTML which is designed by my boss and I dont want to complicate things for him.

    OK Now for the problem

    I have tried to add a counter which goes round the loop until it gets to 100 and execute the loop again ceating another Send mail link with another 100 adresses in it. but i doesnt work. The link works but all the emails are in it and when i open it up to all the database the link falls over. I have used 10 for testing purposes.

    Im sure its something trivial but can anyone help me?

    Thanks

    Keith

  2. #2
    SitePoint Addict kivison's Avatar
    Join Date
    Dec 2004
    Location
    Whitley Bay, Tyne & Wear, UK
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have re jigged the code to get this
    PHP Code:

    while ($clients mysql_fetch_array($clientquery)AND $count10) {
                
    $LeadIDNumber $clients['LeadIDNumber'];
    $FirstName =$clients['FirstName'];
    $LastName =$clients['LastName'];
    $EmailName =$clients['EmailName'];
    echo 
    "$EmailName;";
    $count++;
                            
                            
        }
        
        echo 
    "'>Send mail</a>" 
    Which will output only 10 emails but I am struggling now to get it to output the emails in chunks of 10 until the list is all output.

    Can anyone help??

    Keith

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2004
    Location
    Sydney, Australia
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So basically what your trying to do is for every 10 email addresses you want to create a link?

    If so use this.....

    PHP Code:
    $clientquery = @mysql_query($select $from $where $bywhat) or die('<p>Error retrieving email addresses from database!<br />Error: ' mysql_error() . '</p>'); 

    $count    0;
    $num    10;
    $tmp    null;

    while (
    $clients mysql_fetch_array($clientquery)) { 

        
    $LeadIDNumber    $clients['LeadIDNumber']; 
        
    $FirstName        $clients['FirstName']; 
        
    $LastName        $clients['LastName']; 
        
    $EmailName        $clients['EmailName']; 
        
        
    $tmp             .= $EmailName;
        
        if(
    $i $num == 0) {
        
            echo 
    '<a href="Mailto:me@testemailaddress.co.uk?subject='$message .'&bcc='$tmp .'">Send mail</a>'
            
    $tmp null;
        
        }
        
        
    $count++; 


    What this does is instantly loop through your db records. It appends your email addresses to the $tmp variable. When $i / $num remainder is 0 then we display the email link, with and echo the $tmp variable. The $tmp variable is then reset and we continue with the next 10 records.

    Keep it real

  4. #4
    SitePoint Addict kivison's Avatar
    Join Date
    Dec 2004
    Location
    Whitley Bay, Tyne & Wear, UK
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are a genious!

    Ive been at this all day nearly! It is much simpler this way! However This creates 10 emails to one recipient each instead of one with 100.
    Also (please forgive the ignorance) I dont understand what $i % is doing in this line
    PHP Code:
     if($i $num == 0) { 
    ?

    Were nearly there! Im so happy!

    Keith

  5. #5
    SitePoint Addict kivison's Avatar
    Join Date
    Dec 2004
    Location
    Whitley Bay, Tyne & Wear, UK
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with the maths

    Im nearly there Guys Just a liitle help with the logic and the maths. Here is the code.
    PHP Code:
    $tmp.= "$EmailName;"
         
        if(
    $count $num == 1) { 
         
            echo 
    '<a href="Mailto:me@testemailaddress.co.uk?subject='$message '&bcc='$tmp $bodytext .'">Send mail</a><br>'
            
    $tmp NULL
         
        } 
         
         
    $count++; 
    I need the maths to work out if the number (count) when devided by the number of email addresses in a single email as bcc's is a whole number:- ie

    $count/$num ==1 bit is wrong.

    10/10=1=true
    12/10=1.2=false
    20/10=2=true

    and so on.

    thanks in advance

    Keith


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
  •