Jump to content

bradkenyon

Members
  • Posts

    179
  • Joined

  • Last visited

    Never

Everything posted by bradkenyon

  1. It is datetime. So its alright to leave as is? I just want to be sure I am following proper guidelines, so it doesn't bite me in the butt later on.
  2. I thought the proper format that is wise to use is YYYYMMDDHHMMSS? I just want to make sure I am being the most efficient?
  3. stupid me entered dates into the table poorly. here is a screen shot of how they are entered. YYYY-MM-DD HH:MM:SS When it should be YYYYMMDDHHMMSS How could I go about running a query to change them appropriately in the table? Thanks in advance. [attachment deleted by admin]
  4. Would one table hold all the different types of venues with a unique id for each, which will be stored in the volunteers table under the venue column?
  5. sadly I only use one table. I know, a no no What do you mean fk/pk? I haven't coded anything for assigning a volunteer to a venue, that is what I'm planning to do
  6. thank you I know how to do that, but isn't it a little more elaborate when updating multiple records at the click of a button Because you'll assign all the volunteers to a specific venue from a drop down list of possible choices, then it will go thru the list and plug the updates to each record Maybe a while loop to go down the list and plug each one into the db table?
  7. I have a system that stores volunteers for a festival. I am about to redesign it, to make it more efficient. Currently I have it list their name, and I have an update/delete/view option next to it. I envision adding another column to that volunteer listing, a drop down w/ all the different venues that this volunteer can be assigned to. I want to know how you would be able to go down thru the list and select a venue for each volunteer in the list, then hit submit when I am done selecting each venue from each drop down list. So when I hit submit, it will automatically assign/update every volunteer w/ the appropriate venue (based on which one you selected from that drop down list. I'm not asking for the code, but asking for an explanation of how I would go about this, php and mysql wise. Thank you very much.
  8. 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; ?>
  9. 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.
  10. 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.
  11. 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
  12. 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.
  13. Why do you have: <script type="text/javascript" id="validateScript" src="validate_ind.js"></script> in here: <head> <script type="text/javascript" id="validateScript" src="validate_ind.js"></script> <script type="text/javascript"> function changeValidation(validateID) { document.getElementById('validateScript').src = 'validate_' + validateID + '.js'; } </script> </head>
  14. I am not a very effiecient coder, so I am looking to break down an almost duplicated process into one, and just call the function for three different instances. I send out two emails, one to students, and one to faculty. Both receive the following three things: today's events, upcoming events, and food items Each pull different data into each email, besides the food, that goes to both, and any events that are marked as "both" 2 = students 3 = faculty 1 = both (go to both faculty and students) food = 4 (go to both faculty and students) here is the code that sends the email. i am thinking i can just have one function, that does a bunch of checks for if there is a value in that field of the record, then include it, otherwise don't display it in the email. help would be greatly appreciated. this code calls the function to send the email to appropriate email: eventEmail('2','Student Daily Bulletin','students@domain.com'); eventEmail('3','Faculty/Staff Daily Bulletin','faculty@students.com'); this is the code that pulls the appropriate data for today's events, upcoming events, and food items: <?php require_once("../customemailer/htmlMimeMail.php"); include('../cgi-bin/newsinclude/db.php'); function eventEmail($type, $subject, $emailto) { $today = date("Y-m-d"); //query for today's event $query = "select * from calendar_items WHERE expiredate LIKE '$today %' and (event_type_id = '$type' or event_type_id = 1)"; $result=mysql_query($query); //query for future upcoming event to appear today $upcoming = "select * from calendar_items WHERE upcoming_event_featured_date LIKE '$today %' and (event_type_id = '$type' or event_type_id = 1)"; $result_upcoming=mysql_query($upcoming); //query for food items to appear today $fooditems = "select * from calendar_items WHERE expiredate LIKE '$today %' and event_type_id = '4'"; $result_fooditems=mysql_query($fooditems); print '<h1 style="color:red;">'.mysql_num_rows($result).'</h2>'; print '<h1 style="color:red;">'.mysql_num_rows($result_upcoming).'</h2>'; //if there is an event, then proceed, otherwise do not send email if(mysql_num_rows($result) > 0 || mysql_num_rows($result_upcoming) > 0 || mysql_num_rows($result_fooditems) > 0) { //checks to see if there is an event for today if(mysql_num_rows($result) > 0) { print '<h1>Today '.$type.'</h1>'; $message.="<h1 style=\"font-size:16px;\">Today's Events</h1>"; ?> <ul> <?php while($row = mysql_fetch_array($result)) { $i = 0; while($i <=0) { 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>'; $message.= "<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']) { $message.='<br>Document Attached: <a href="http://herkimer.edu/docs/?docid='.$row['id'].'">Click to download</a>'; } $i++; print '</p>'; } } print '</ul>'; } //checks to see if there is a future event that is displayed in today's email if(mysql_num_rows($result_upcoming) > 0) { print '<h1>Events down the road...</h1>'; $message.="<h1 style=\"font-size:16px;\">Events down the road...</h1>"; while($row_upcoming = mysql_fetch_array($result_upcoming)) { $u = 0; while($u <=0) { print '<p>'.$row_upcoming['subj'].$row_upcoming['id'].'</p>'; print '<p><strong>'.date("l F j, Y",strtotime($row_upcoming['expiredate'])).'</strong> - <a href="/events/?id='.$row_upcoming['id'].'">'.$row_upcoming['subj'].'</a> - <small>'.$row_upcoming['location'].'</small></p>'; $message.= "<p><span style=\"font-weight:bold; color:#00472D; font-size:14px;\">".$row_upcoming['subj']."</span><br /> <span style=\"font-size:14px;\">".date("l F j, Y",strtotime($row_upcoming['expiredate']))." / ".$row_upcoming['location']."<br /> ".nl2br($row_upcoming['body'])."</span>"; if($row_upcoming['docurl']) { $message.='<br>Document Attached: <a href="http://herkimer.edu/docs/?docid='.$row_upcoming['id'].'">Click to download</a>'; } $u++; print '</p>'; } } } //checks to see if there is a food item to send within the email if(mysql_num_rows($result_fooditems) > 0) { print '<h1>Dining Choices</h1>'; $message.="<h1 style=\"font-size:16px;\">Dining Choices</h1>"; while($row_fooditems = mysql_fetch_array($result_fooditems)) { $f = 0; while($f <=0) { print '<p>'.$row_fooditems['subj'].$row_fooditems['id'].'</p>'; $message.= "<p><span style=\"font-weight:bold; color:#00472D; font-size:14px;\">".$row_fooditems['subj']."</span><br /> <span style=\"font-size:14px;\">".date("g:ia",strtotime($row_fooditems['expiredate']))." / ".$row_fooditems['location']."<br /> ".nl2br($row_fooditems['body'])."</span>"; if($row_fooditems['docurl']) { $message.='<br>Document Attached: <a href="http://herkimer.edu/docs/?docid='.$row_fooditems['id'].'">Click to download</a>'; } $f++; print '</p>'; } } } //if there something in result and/or result_upcoming, it will run this $mail = new htmlMimeMail(); $mail->setHTML($message); $mail->setSubject($subject); $mail->setFrom("no-reply@domain.com"); $result = $mail->send(array($emailto)); //echo $result ? 'Mail sent!' : 'Failed to send mail'; } else { print '<p>Nothing to send in the email, so it was not sent.</p>'; } } function DownloadFile($file) // $file = include path { if(file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit; } } ?>
  15. I want to present a drop down menu, which a person will select from the following: Student Events Student Announcement Faculty Events Faculty Announcements Announcements (Both) Events (Both) Food Menu Items I plan on keeping the form the same, but based off of what kind of item they select to enter, then I want to include the appropriate .js validation form for it. So if someone selects Student Events, I want it to use the student_events.js file, which will validate the appropriate fields, because some items will need to be required and some won't, so I want to plug in the correct validation file based on what item they're selecting. so like I said, if they select Student Events, plug in <script src="student_events.js" type="text/javascript"></script> All items will use the same form, just certain items will have different required fields on the form. Hope this makes sense. so I envision there will an onselect event which will trigger a case or conditional if student events use: <script src="student_events.js" type="text/javascript"></script> if faculty events use: <script src="faculty_events.js" type="text/javascript"></script> so on and so forth any help is greatly appreciated. thank you.
  16. Thanks, that worked. Modded it a little, to do a check to see if the docid actually has a file associated w/ it. As well if it is a valid id. Now I want to know why whenever I test using a valid id, but the id doesn't has an empty docurl, it prints out "downloaded" and doesn't print out "no file for that id" <?php include('../cgi-bin/cms/collegeevents/email_function.php'); $docid = $_GET['docid']; if($row['docurl'] != '') { $query = "SELECT * FROM calendar_items WHERE id = '$docid' LIMIT 1"; $result = mysql_query($query); if(mysql_num_rows($result) > 0) { $row = mysql_fetch_array($result); if($row['docurl']) { DownloadFile($row['docurl']); print 'downloaded'; } else { print 'no file for that id'; } } else { print 'invalid id'; } }?> nevermind, it works. thank you!
  17. I have a download script, and I only want it to run if the id is found in the db table, which refers to the document filename. I think you have to test to see if the number of times it is found, which should be once, since it is a unique id, then it should be a test for if it is larger than 0, then run the script, if not, then display a msg saying no file w/ that id. Here is what I have: <?php include('../cgi-bin/cms/collegeevents/email_function.php'); $docid = $_GET['docid']; if(!$docid == '') { $query = "SELECT * FROM calendar_items WHERE id = '$docid'"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { print mysql_num_rows($result); if(mysql_num_rows($result) > 0) { DownloadFile($row['docurl']); print 'downloaded'; } else { print 'no file for that id'; } } } ?> Any help is appreciated.
  18. I have an document upload form. <input type="file" name="doc_uploaded"> The below code is how I grab the file the user browsed on their hard drive and uploaded. I want to the filename to be all lowercase and replace any spaces w/i the filename w/ underscores, which will take some regex. Could anyone help, thanks! <?php $fileget_doc=$_FILES['doc_uploaded']['name']; if($fileget_doc) { $filename_doc = date(mdyhms).$fileget_doc; } else { $filename_doc = ''; } if($filename_doc != '') { $target_doc = "/web/images/news/"; $target_doc = $target_doc . basename( date(mdyhms).$_FILES['doc_uploaded']['name']); $ok=1; if(move_uploaded_file($_FILES['doc_uploaded']['tmp_name'], $target_doc)) { //echo "The file ".basename( $_FILES['doc_uploaded']['name'])." has been doc_uploaded"; } else { //echo "Sorry, there was a problem uploading your file."; } }?>
  19. I print out count($result) and count($result_upcoming) and both display the value 1. even with both having more than 1 event for both result and result upcoming. or is it referring to 1 as being true and 0 being not true, not true meaning, no events, true, meaning there are events. but when i have no events for either, it still sets the value to of result and upcoming_result to 1.
  20. what would that query look like? i want to test both queries for if the count if zero. because both result, and upcoming_result need to be zero to not send out an email. because the email can still be sent to display the upcoming events even on days it has no events. the way upcoming events works, you can set an event to display in the daily event emailer a week, month, year ahead, whenever you set the day for it to display, it gives you the option to feature the event a week or month a head of time, instead of just the day of event, gives them more notice. so i want to make sure, if both is 0, then don't send it, but if either is over 0, then send it.
  21. i have a script that pulls events from a table and sends the events in an email. i want to only send an email when there are events for that day. if there are no events, whats the point of sending them. this is what I have now, with no checking in place I have a check for if($result_upcoming), and if($result) - i don't think those if's are doing any good, since they both contain values of resource id's, so when i went to test w/ something along these lines.... if there is nothing in result_upcoming or result, then don't send the email result_upcoming, is upcoming events, to be featured at the bottom of the email result, is the events for that day ya ya, i should of came up w/ a better naming convention. what should i do to check to see if there are no events and no upcoming events for that day, to not send the email? Thanks in advance. <?php require_once("../customemailer/htmlMimeMail.php"); include('../cgi-bin/newsinclude/db.php'); function eventEmail($type, $subject, $emailto) { $today = date("Y-m-d"); //query for today's event $query = "select * from calendar_items WHERE expiredate LIKE '$today %' and event_type_id = '$type'"; $result=mysql_query($query); //query for future upcoming event to appear today $upcoming = "select * from calendar_items WHERE upcoming_event_featured_date LIKE '$today %' and event_type_id = '$type'"; $result_upcoming=mysql_query($upcoming); print '<h1>'.$type.'</h1>'; //if either has an event, then run and send something in the email, otherwise, don't do either if($result || $result_upcoming) { //checks to see if there is an event for today if($result) { print '<h1>Today</h1>'; $message.="<h1>Today's Events</h1>"; ?> <ul> <?php while($row = mysql_fetch_array($result)) { $i = 0; while($i <=0) { 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>'; $message.= "<h3>".$row['subj']."</h3> <p><strong>When:</strong> ".date("g:ma",strtotime($row['expiredate']))."<br /> <strong>Where:</strong> ".$row['location']."</p> <p>".nl2br($row['body'])."</p>"; $i++; } } print '</ul>'; } //checks to see if there is a future event that is displayed in today's email if($result_upcoming) { print '<h1>Events down the road...</h1>'; $message.="<h1>Events down the road...</h1>"; while($row_upcoming = mysql_fetch_array($result_upcoming)) { $u = 0; while($u <=0) { print '<p>'.$row_upcoming['subj'].$row_upcoming['id'].'</p>'; $message.= "<h3>".$row_upcoming['subj']."</h3> <p><strong>When:</strong> ".date("l F j, Y g:ma",strtotime($row_upcoming['expiredate']))."<br /> <strong>Where:</strong> ".$row_upcoming['location']."</p> <p>".nl2br($row_upcoming['body'])."</p>"; $u++; } } } //if there something in result and/or result_upcoming, it will run this $email = 'no-reply@domain.com'; $mail = new htmlMimeMail(); $mail->setHTML($message); $mail->setSubject($subject); //$mail->setFrom($email); //$result = $mail->send(array($emailto)); //echo $result ? 'Mail sent!' : 'Failed to send mail'; } else { print 'Nothing to send in the email, so it was not sent.'; } } ?>
  22. if(empty($_POST)) {} did not work. i have a feeling when i hit submit for the update form, it loops back around and checks to see if you're the author of the event you're trying to update and craps out. or something w/ the queries.
×
×
  • 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.