Jump to content

robatojazzo

New Members
  • Posts

    7
  • Joined

  • Last visited

Posts posted by robatojazzo

  1. Ok so for distance I added something that may complicate my code.  The realtor is willing to travel a certain distance in miles.  I added a column in my MySQL called willToTravel.  The data in that column is in miles.

    `willToTravel` int(11) NOT NULL,

    Ok so based off that information I needed clients to that are in the distance range of willToTravel.  Do you think it will be a good idea to calculate using 

    acos and cos? 

  2. Thanks ok I see.  What was I thinking before?  To be honest I used another forum besides this one and devshed for help and I'm still learning mySQL.  My problem is I took on a big project and jumped in without a life jacket.  I just needed to break this down so I can understand what I'm trying to do.  It was a choice between mySQL or Access.  I'm really migrating from a windows environment to linux.  I like linux just a super newbie thats it.

     

    Well with the project the script is working but now its emailing everybody even if they don't have customers in their area.  I set up test emails for the realtors using gmail.  I was thinking maybe making a email list with a time variable.

  3. Sorry I took to long to reply but Ok so I changed my code and emails are going to their respected recipients.  The only problem is that there is two registered customers that is within distance of realtor_2.  Only one of the email address show up.  I was thinking of maybe of making a new table for matches.  So I did a print_r to see what was going on and this is what I got.

    Array
    (
        [rid] => 2
        [0] => 2
        [rEmail] => realtor_2@gmail.com
        [1] => realtor_2@gmail.com
        [id] => 3
        [2] => 3
        [eMail] => cust_1@coolmail.com
        [3] => cust_1@coolmail.com
    )
    Array
    (
        [rid] => 4
        [0] => 4
        [rEmail] => realtor_1@gmail.com
        [1] => realtor_1@gmail.com
        [id] => 2
        [2] => 2
        [eMail] => cust_2@google.com
        [3] => cust_2@google.com
    )
    Array
    (
        [rid] => 5
        [0] => 5
        [rEmail] => realtor_3@gmail.com
        [1] => realtor_3@gmail.com
        [id] => 
        [2] => 
        [eMail] => 
        [3] => 
    )
    

    This is the foreach loop. 

     
    $realtCust_row = $realtCust->fetch(PDO::FETCH_ASSOC);
    
    foreach ($realtCust as $realtCust_row):
    
      //send an email to the realtor email containing the customer email.
    
     $msgBody = "This is a test";
    
     // use wordwrap() if lines are longer than 70 characters
     $msgBody = wordwrap($msgBody,70);
    
     $Mailto = $realtCust_row['rEmail'];
    
     $FromEmail = $realtCust_row['eMail'];
    
      //mail($Mailto, $FromEmail , $msgBody);
    
    
    echo "<pre>";
        print_r($realtCust_row);
    echo "</pre>";
    
    endforeach;
  4.  I'm trying to get my code to email the associate realtor.  For example if realtor 1 has customers 1, 3, 5, 10 within range then I want to send 1 email notification per customer with their email information to realtor 1.  This is pretty complex code well to me but i been trying different ways to do this like using an associative array.  Sorry for being vague but I'm pressed for time on my final project. 

  5. I updated my code.

    $realtCust = $db->prepare("SELECT
    rid
    , rEmail
    ,id
    , eMail
    FROM realtors r
    LEFT JOIN
    customers c
    ON pow(clatitude-rlatitude, 2) + pow(clongitude-rlongitude, 2) < pow(100/110.25, 2)
    ORDER BY rid, id");
    
    $realtCust->execute();
    $realtCust->rowCount();
    $realtCust_row = $realtCust->fetch(PDO::FETCH_ASSOC);
    $rcArray = array(
    [$realtCust_row['rid'],$realtCust_row['rEmail']],
    [$realtCust_row['id'],$realtCust_row['eMail']],
    
    );
    $rcArray = array(
    [$realtCust_row['rid'],$realtCust_row['rEmail']],
    [$realtCust_row['id'],$realtCust_row['eMail']],
    
    );
    foreach( $rcArray as list( ,$rcEmail)) {
    //echo "$a\n";
    
    echo $rcEmail;
    }
  6. I'm trying to check two see if the customer is within range of the realtor and if so to email that realtor. So far I got to the point where I can calculate the distance in the query. So since I can match those that are in distance how to check if two columns match? I need to know if two columns match what is the best way for this to be done?

    Here is my php code.

    
    
               $realtCust = $db->prepare("SELECT
                    rid
                  , rEmail
                  ,id
                  , eMail
                FROM realtors r
                    LEFT JOIN
                  customers c
                    ON pow(clatitude-rlatitude, 2) + pow(clongitude-rlongitude, 2) < pow(100/110.25, 2)
                ORDER BY rid, id");
                
                $realtCust->execute();
                $realtCust->rowCount();
        $realtCust_row = $realtCust->fetch(PDO::FETCH_ASSOC);
        $rcArray = array(
             [$realtCust_row['rid'],$realtCust_row['rEmail']],
             [$realtCust_row['id'],$realtCust_row['eMail']],
        
        );
        foreach( $rcArray as mail($rcEmail,)) {
            //echo "$a\n";
          if($arraysAreEqual = ($rcEmail==$rcEmail))
        
            mail();
        
          }else{
            echo "don't work";
          }
        }
    
     
×
×
  • 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.