Jump to content

searls03

Members
  • Posts

    907
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://troop078.net46.net

Profile Information

  • Gender
    Not Telling

searls03's Achievements

Advanced Member

Advanced Member (4/5)

1

Reputation

  1. I am working on trying to integrate send grid into my website. I am a bit newer at this. I am working on trying to set up batchids and scheduled sending (sendAt). Scheduling works when there is only one email that it is going to, however It will send right away when there is more than one email. Can anyone offer any assistance on how to get this properly set up? require '../sendgrid/vendor/autoload.php'; // If you're using Composer (recommended) use SendGrid\Mail\From; use SendGrid\Mail\HtmlContent; use SendGrid\Mail\Mail; use SendGrid\Mail\PlainTextContent; use SendGrid\Mail\To; use SendGrid\Mail\SendAt; use SendGrid\Mail\BatchId; $from = new From("email", "name"); $sql1 = "SELECT * from database where sent='no'"; $tos=array(); $result1 = $conn->query($sql1); if ($result1->num_rows > 0) { // output data of each row while($row1 = $result1->fetch_assoc()) { $first= $row1["first"]; $last= $row1["last"]; $date= $row1["date"]; $email=$row1['email']; $tos[]= new To( "$email", "$first $last", [ '{{First_Name}}' => $first, '{{Last_Name}}' => $last, '{{testing}}' => $date, '{{email}}' => $email, ], "View your Testing Report Card!" ); } } $globalSubstitutions = [ '-time-' => "2018-05-03 23:10:29" ]; $plainTextContent = new PlainTextContent( "Good Morning!<br> <br> {{First_Name}}'s report card from the {{testing}} testing is ready to view.<br> <br> Please click the link below to view. <br> <br>Login with the following:<br> Name: {{First_Name}}<br> Email: {{email}}.<br> <br> " ); $htmlContent = new HtmlContent( "Good Morning!<br> <br> {{First_Name}}'s report card from the {{testing}} testing is ready to view.<br> <br> Please click the link below to view. <br> <br>Login with the following:<br> Name: {{First_Name}}<br> Email: {{email}}.<br> <br> " ); $sendgrid = new \SendGrid('apikey'); try { $response = $sendgrid->client->mail()->batch()->post(); print $response->statusCode() . "\n"; print_r($response->headers()); $batch= $response->body() . "\n"; echo $batch."<br> <br> <br> "; } catch (Exception $ex) { echo 'Caught exception: '. $ex->getMessage(); } $data = json_decode($batch); $batchnew= $data->batch_id; $sendtime=strtotime("today 9:02"); $email = new Mail( $from, $tos, $subject, // or array of subjects, these take precedence $plainTextContent, $htmlContent, $globalSubstitutions ); $email->setSendAt($sendtime); $email->setBatchId($batchnew); try { $response = $sendgrid->send($email); print $response->statusCode() . "\n"; print_r($response->headers()); print $response->body() . "\n"; } catch (Exception $e) { echo 'Caught exception: '. $e->getMessage(). "\n"; } I edited the code to not include personal information. As you can see, I run a loop at the start to create an array of data for the to addresses. This sends multiple emails (not just one email with multiple to's). However, no matter what I put in the for sendat time, it sends it right away when there is more than one email present. I tried creating a batch id then getting the id via json and then setting the batch id, but it still sends right away. Any help would be appreciated!
  2. I am trying to run two queries within one I guess you could say. What I am trying to do is build a scoring system where each person gets two chances. The least number is their best. What I need to have happen is for the php query to select the smallest number for each person, then display the 3 names of the people with the 3 smallest numbers. I am guessing I need to use a query like this to get the smallest number for each person: $sql = mysql_query("SELECT LEAST(MIN(COL1),MIN(COL2))FROM yourtable;"); but after this I am stumped as to how to make it display the names associated with the 3 smallest numbers. Can anyone help me out?
  3. and this is in a PHP insert query btw.
  4. Hi, I am completely stuck on this. I am trying to allow the user to select a start day and end day. then the system adds two weeks to the start day and each previous calculation (ie intervals of 0 weeks, 2 weeks, 4 weeks, etc. from the start day) until the end date is reached. I would also like each of these dates to be inserted into my database. I have no clue as to where to even start with this. I know I will need some kind of loop based on days, but I am not sure how I would write this. I suppose this would be the basic structure of the query, but not sure how to incorporate this loop that I need. mysql_query("INSERT INTO events (title, date) VALUES ('$title', '(current date that the loop is in)')"); mysql_error(); can anyone help me out with this? thanks in Advance!
  5. sorry, I was thinking in the current query it says date, not start. start IS in the query....like it says right after that. sorry
  6. hi I have a code that puts events into a calendar. I am doing a new calendar for a new client and have some different issue that are arising. the original code I have is meant for a "one day" event. I am now trying to place in a "multi-day" event. how can I change this query to a multi-day selector. $result = mysql_query("SELECT * FROM events where start='".$m1."/".sprintf ("%02u", $d)."/".$year."'"); I need to keep everything after "start =" the same. However, start is nolonger in my database, it is start and end. How can I generate a query that selects it for multiple dates where it is between start and end. does this make sense? thanks
  7. my php query: <?php $sql1 = mysql_query("SELECT * FROM attendance ORDER BY id ASC"); while($row1 = mysql_fetch_array($sql1)){ $current = $row1["id"]; $name = $row1["name"]; echo $current; echo "<br>"; } is not sorting properly. it is putting all 6 digit numbers before 5 digit numbers....here is what it is returning 100000 ... 311655 311657 311711 311789 311790 311791 311792 311793 311794 311795 69326 69390 69451 69547 99985 99989 99990 99991 99992 99993 99995 99996 99997 99998 99999 does it have anything to do with the numbers not being consecutive? I can't have this.......I have another insert query that adds one to the last number output....which clearly it won't do because the new would be the same as the first number. can anyone help me with this?
  8. hi all. I am looking for a way to order a php query result by a specific value, not like an id ASC, but like first column 1=red(there could be multiples, so all that have column 1 as red display first), then column2=blue. I have been looking all day and havent been able to find anything. any help?
  9. Actually that fate won't be there anymore, the "date" for reference will be created via php.
  10. hello all, I have been working on a calendar system for someone, and they were using one date events....now they want events with a range. I have this code working to select one date $result = mysql_query("SELECT * FROM classes where date='".$m1."/".sprintf ("%02u", $d)."/".$year."'");....this is fine, don't critique it please. My data base now has a start date and an end date fields in them. I need to know how I can pull the data if the date that I want to display falls inbetween or on those startdate and enddate field. so for example, May 1st through the 5th is an event called test i would like it to pull data and then display it similar to this: 1-test 2-test 3-test 4-test 5-test the numbers being the May "date". can anyone help me with this?
  11. no, cURL stays on current page
  12. and I don't want to do it via a form because it would contain prepopulated sensitive info
  13. Wish I could, but I need a way where it will actually go to the page with the posted variable present. So the same page an HTML form would go to.
  14. this may be a vague question, but is there a way for PHP to generate a POST variable and then send that variable to a page on a different server? so PHP creates lets say a POST variable for "name" (this should be equivalent to an html form with the name of "name"), so then it can submit to a form on an external server that only accepts specific names of elements? does this make sense?
  15. so I finally have this working! <?php date_default_timezone_set('America/Los_Angeles'); error_reporting(E_ALL); ini_set("display_errors", 1); $offset = isset($_GET['offset']) ? intval($_GET['offset']) : 0; $currMonth = date('n'); $list = array(); $list[] = mktime(0, 0, 0, $currMonth+$offset, 1); $list[] = mktime(0, 0, 0, $currMonth+$offset+1, 1); $list[] = mktime(0, 0, 0, $currMonth+$offset+2, 1);?> <table> <?php foreach ($list as $dateTS){ echo '<tr style="background-color:#CCC"><td>'; echo '<strong>'.date('F Y', $dateTS) . '</strong><br /> </td></tr>'; $sql = mysql_query("SELECT * FROM events where public='yes' order by id ASC"); while($row = mysql_fetch_array($sql)){ $start1 = $row["start"]; $end1 = $row['end']; $event = $row['name']; $id = $row['id']; $start = new DateTime($start1); $end = new DateTime($end1); $inc = DateInterval::createFromDateString('first day of next month'); $end->modify('+1 day'); $p = new DatePeriod($start,$inc,$end); foreach ($p as $d) if($d->format('M Y')==date('M Y', $dateTS)){ $originalDate = $start1; $newDate = date("m/d/Y", strtotime($originalDate));$originalDate1 = $end1; $newDate1 = date("m/d/Y", strtotime($originalDate1)); echo '<tr><td><a href="event.php?id='.$id.'">' .$newDate.' - '.$newDate1.' '.$event.'</a><br /></tr></td>'; } } } $prev = $offset-3; $next = $offset+3; echo "<br><a href='?offset={$prev}'>Prev</a> <a href='?offset={$next}'>Next</a>"; ?> I do have one issue though, how and where do I place a message that will display no events scheduled if the month has no events scheduled?
×
×
  • 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.