bradkenyon Posted September 10, 2008 Share Posted September 10, 2008 This code grabs the records w/ today's day, as well as the items w/ 'upcoming_event_featured_date' like today's date as well. This is the code that grabs the appropriate records <?php $query = "select * from calendar_items WHERE expiredate LIKE '$tdate %' or upcoming_event_featured_date like '$tdate %' and (event_type_id = '$type' or event_type_id = 1 or event_type_id = 4 or event_type_id = 6 or event_type_id = 7 or event_type_id = 2)"; $result=mysql_query($query); if(mysql_num_rows($result) > 0) { print '<h1>Today '.$type.'</h1>'; ?> <ul> <?php while($row = mysql_fetch_array($result)) { $i = 0; print '<h1>'.$row['upcoming_event_featured_date'].'</h1>'; while($i <=0) { if($row['event_type_id'] == $type || $row['event_type_id'] == $both_e) { print '<h2 style="color:purple;">'.$row['upcoming_event_featured'].'</h2>'; if($row['upcoming_event_featured'] == 1 && ($row['event_type_id'] == $type || $row['event_type_id'] == $both_e)) { $upcoming.="<h1 style=\"font-size:16px;\">Events down the road...</h1>"; print '<p><strong>'.date("l F j, Y",strtotime($row['expiredate'])).'</strong> - <a href="/events/?id='.$row['id'].'">'.$row['subj'].'</a> - <small>'.$row['location'].'</small></p>'; $upcoming.= "<p><span style=\"font-weight:bold; color:#00472D; font-size:14px;\">".$row['subj']."</span><br /> <span style=\"font-size:14px;\">".date("l F j, Y",strtotime($row['expiredate']))." / ".$row['location']."<br /> ".nl2br($row['body'])."</span>"; if($row['docurl']) { $upcoming.='<br>Document Attached: <a href="http://college.edu/docs/?docid='.$row['id'].'">Click to download</a>'; } } else { $today.="<h1 style=\"font-size:16px;\">Today's Events</h1>"; print '<p><strong>'.date("l F j, Y",strtotime($row['expiredate'])).'</strong> - <a href="/events/?id='.$row['id'].'">'.$row['subj'].'</a> - <small>'.$row['location'].'</small></p>'; $today.= "<p><span style=\"font-weight:bold; color:#00472D; font-size:14px;\">".$row['subj']."</span><br /> <span style=\"font-size:14px;\">".date("g:ia",strtotime($row['expiredate']))." / ".$row['location']."<br /> ".nl2br($row['body'])."</span>"; if($row['docurl']) { $today.='<br>Document Attached: <a href="http://college.edu/docs/?docid='.$row['id'].'">Click to download</a>'; } } } elseif($row['event_type_id'] == $announcement_id || $row['event_type_id'] == $both_a){ $announcement.="<h1 style=\"font-size:16px;\">Today's Announcements</h1>"; print '<p><strong>'.date("l F j, Y",strtotime($row['expiredate'])).'</strong> - <a href="/events/?id='.$row['id'].'">'.$row['subj'].'</a> - <small>'.$row['location'].'</small></p>'; $announcement.= "<p><span style=\"font-weight:bold; color:#00472D; font-size:14px;\">".$row['subj']."</span><br /> ".nl2br($row['body'])."</span>"; if($row['docurl']) { $announcement.='<br>Document Attached: <a href="http://college.edu/docs/?docid='.$row['id'].'">Click to download</a>'; } } elseif($row['event_type_id'] == $food_id){ $food.="<h1 style=\"font-size:16px;\">Dining Choices</h1>"; print '<p><strong>'.date("l F j, Y",strtotime($row['expiredate'])).'</strong> - <a href="/events/?id='.$row['id'].'">'.$row['subj'].'</a> - <small>'.$row['location'].'</small></p>'; $food.= "<p><span style=\"font-weight:bold; color:#00472D; font-size:14px;\">".$row['subj']."</span><br /> ".nl2br($row['body'])."</span>"; if($row['docurl']) { $food.='<br>Document Attached: <a href="http://college.edu/docs/?docid='.$row['id'].'">Click to download</a>'; } } $i++; print '<h2 style="color:orange;">'.$i.'</h2>'; print '</p>'; } } } ?> here is the code that specifies which is which: function eventEmail($type, $subject, $emailto) { $tdate = date("Y-m-d"); print $tdate; switch($type) { case "2": $both_e = 1; $both_a = 7; $announcement_id = 5; $food_id = 4; include('email_case.php'); break; case "3": $both_e = 1; $both_a = 7; $announcement_id = 6; $food_id = 4; include('email_case.php'); break; } $mail = new htmlMimeMail(); $message = $today.$announcement.$food.$upcoming; $mail->setHTML($message); $mail->setSubject($subject); $mail->setSMTPParams('mail1.college.edu', 25); $mail->setFrom("no-reply@college.edu"); $mail->setReturnPath("webmaster@college.edu"); if($message) { //$mailresult = $mail->send(array($emailto)); } } here is the call to the function: <?php eventEmail('2','Student Daily Bulletin','students@college.EDU'); eventEmail('3','Faculty/Staff Daily Bulletin','faculty@college.EDU'); ?> it emails to both emails the appropriate items, but the problem is something w/ the while loop w/ multiple items. there are following types of items: announcements events food upcoming (upcoming events) It seems like something is up w/ the while loop because if there is multiple events, it will display the header twice "Today's Events" within the email, when it should only display it once and list the two events under that header. I have a feeling there should be multiple while loops within the if else statements. Any help is very appreciated. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
bradkenyon Posted September 10, 2008 Author Share Posted September 10, 2008 btw...this is what it displays in the email it sends an email that looks something like this (notice how the heading "Today's Events" shows up twice): Today's Events Leadership Development Series: Recruiting and Retaining Members 12:30pm / RMCC 217 Presented by Marc Cianciola, Assistant Director of Student Activities Are you a leader? Are you constantly looking for new members? When new members join do they only stay for a few weeks and are never seen again? Come learn some tips for recruiting new members and also how to keep them involved in your organization. Today's Events Men's Soccer vs. Fulton-Montgomery Community College 6:00pm / Wehrum Stadium Men's Soccer vs. Fulton-Montgomery Community College Dining Choices Dining Center Specials Sausage Pizza Soup Grill: Chicken, Ham & Cheese Sandwich Hot Line: Mac & Cheese, Spanish rice, and Sauteed Snow Peas I imagine it occurs to any of the various item types (today events, announcements, upcoming, food) that have more than one item, but in this example, only "Today's Events" does, the rest only have one item the day. --------------------------------------------------------------------------------------------------------------------- It should display within the email like this: Today's Events Leadership Development Series: Recruiting and Retaining Members 12:30pm / RMCC 217 Presented by Marc Cianciola, Assistant Director of Student Activities Are you a leader? Are you constantly looking for new members? When new members join do they only stay for a few weeks and are never seen again? Come learn some tips for recruiting new members and also how to keep them involved in your organization. Men's Soccer vs. Fulton-Montgomery Community College 6:00pm / Wehrum Stadium Men's Soccer vs. Fulton-Montgomery Community College Dining Choices Dining Center Specials Sausage Pizza Soup Grill: Chicken, Ham & Cheese Sandwich Hot Line: Mac & Cheese, Spanish rice, and Sauteed Snow Peas Quote Link to comment Share on other sites More sharing options...
DamienRoche Posted September 10, 2008 Share Posted September 10, 2008 search for and delete this: $announcement.="<h1 style=\"font-size:16px;\">Today's Announcements</h1>"; Hope that helps. Quote Link to comment Share on other sites More sharing options...
bradkenyon Posted September 10, 2008 Author Share Posted September 10, 2008 Thanks, but that needs to be in there, it displays "announcement" items, its one of the item types, it only displays it if there is an announcement for that day. Quote Link to comment Share on other sites More sharing options...
DamienRoche Posted September 11, 2008 Share Posted September 11, 2008 No, it doesn't need to be in there. It is a continued variable. This displays announcement items: print '<p><strong>'.date("l F j, Y",strtotime($row['expiredate'])).'</strong> - <a href="/events/?id='.$row['id'].'">'.$row['subj'].'</a> - <small>'.$row['location'].'</small></p>'; $announcement.= "<p><span style=\"font-weight:bold; color:#00472D; font-size:14px;\">".$row['subj']."</span><br /> ".nl2br($row['body'])."</span>"; To illustrate this a little more...This is the code for the first part of the "Today's events": $today.="<h1 style=\"font-size:16px;\">[b]Today's Events[/b]</h1>"; print '<p><strong>'.date("l F j, Y",strtotime($row['expiredate'])).'</strong> - <a href="/events/?id='.$row['id'].'">'.$row['subj'].'</a> - <small>'.$row['location'].'</small></p>'; $today.= "<p><span style=\"font-weight:bold; color:#00472D; font-size:14px;\">".$row['subj']."</span><br /> <span style=\"font-size:14px;\">".date("g:ia",strtotime($row['expiredate']))." / ".$row['location']."<br /> ".nl2br($row['body'])."</span>"; ...and this is the code for the second part: $announcement.="<h1 style=\"font-size:16px;\">[b]Today's Announcements[/b]</h1>"; print '<p><strong>'.date("l F j, Y",strtotime($row['expiredate'])).'</strong> - <a href="/events/?id='.$row['id'].'">'.$row['subj'].'</a> - <small>'.$row['location'].'</small></p>'; $announcement.= "<p><span style=\"font-weight:bold; color:#00472D; font-size:14px;\">".$row['subj']."</span><br /> ".nl2br($row['body'])."</span>"; Notice how the <h1> containing Todays Announcements is repeated. That is why you are seeing it twice. Just try it out, you'll see. Hope that helps. Quote Link to comment Share on other sites More sharing options...
bradkenyon Posted September 11, 2008 Author Share Posted September 11, 2008 you're right, it does not need to be in there, I just have it in there to see what it displays, just error checking. that is not my problem. Quote Link to comment Share on other sites More sharing options...
DamienRoche Posted September 11, 2008 Share Posted September 11, 2008 OK, well good luck getting someone else to waste time with you. Quote Link to comment Share on other sites More sharing options...
bradkenyon Posted September 11, 2008 Author Share Posted September 11, 2008 easy. i appreciate your help. solved: <?php while($upcoming_banner_displayed == false): $upcoming.="<h1 style=\"font-size:16px;\">Events down the road...</h1>"; $upcoming_banner_displayed = true; endwhile; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.