Jump to content

SEVIZ

Members
  • Posts

    93
  • Joined

  • Last visited

    Never

Everything posted by SEVIZ

  1. Thank you again for your help. I apologize that this is confusing. I only posted a snippet of my code to highlight my problem but it appears the biggest problem is that you cannot see my entire goal with this snippet. The point of this script is to let a user send an email to a phone from the app. The dropdown holds many choices. Right now I am using a couple queries for the info and I just posted one. Here is my entire code to get a better idea of what I am doing. <?php mysql_connect("localhost", "XXXXX", "XXXXX") or die(mysql_error()); mysql_select_db("TEXT_TOOL") or die(mysql_error()); if (!empty($_POST["recip"])) { $q = "select `num` from sprint WHERE `dept` = '".mysql_real_escape_string($_POST["recip"])."'"; $ret = mysql_query($q); $emails = array(); while ($row = mysql_fetch_assoc($ret)) { $emails[] = $row['num'].'@messaging.sprintpcs.com'; } if ($emails) { $ToEmail = implode(', ', $emails); $EmailSubject = $_POST["subject"]."\r\n"; $mailheader = "From: ".$_POST["email"]."\r\n"; $MESSAGE_BODY = nl2br($_POST["message"]); // $MESSAGE_BODY .= ($_POST["auth"]); mail($ToEmail,$EmailSubject, $MESSAGE_BODY,$mailheader) or die ("Failure"); } ?> <font color="red"><b>Your Text has been sent. The message sent was:</b></font><br /><br /> <font face="tahoma" size="4"><?php echo $_POST["message"]; ?></font> <br /><br /> - <b><a href="text_tool.php">GO BACK</a></b> <?php } else { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="en-us" http-equiv="Content-Language" /> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Text Tool</title> <style type="text/css"> .style1 { text-align: center; } </style> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function textCounter(field, countfield, maxlimit) { if (field.value.length > maxlimit) // if too long...trim it! field.value = field.value.substring(0, maxlimit); // otherwise, update 'characters left' counter else countfield.value = maxlimit - field.value.length; } // End --> </script> </head> <body> <form action="text_tool2.php" method="post"> <table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td valign="top"> Send To:<br /> <select name="recip"> <?php $q = "select `all` from sprint GROUP BY `all`"; $ret = mysql_query($q); while ($row = mysql_fetch_assoc($ret)) { $email_sec = $row['all']; print "<option value=\"$email_sec\">$email_sec North and South</option>"; } ? <!-- THIS ONE DOESNT WORK CURRENTLY --> <?php //$q = "SELECT `dept` FROM `sprint` WHERE dept='T_LEAD' OR dept='T_SUP' GROUP BY `dept`"; $q = "SELECT DISTINCT(`dept`) FROM `sprint` WHERE dept='T_LEAD' OR dept='T_SUP' GROUP BY `dept`"; $ret = mysql_query($q) or die(mysql_error()); while ($row = mysql_fetch_assoc($ret)) { $email_sec = $row['dept']; print "<option value=\"$email_sec\">Leads and Sups</option>"; } ?> <?php $q = "select `loc` from sprint GROUP BY `loc`"; $ret = mysql_query($q); while ($row = mysql_fetch_assoc($ret)) { $email_sec = $row['loc']; print "<option value=\"$email_sec\">$email_sec Only</option>"; } ?> <?php $q = "select `dept` from sprint WHERE dept='S_REP' GROUP BY `dept`"; $ret = mysql_query($q); while ($row = mysql_fetch_assoc($ret)) { $email_sec = $row['dept']; print "<option value=\"$email_sec\">All Sales</option>"; } ?> <?php $q = "SELECT `sup` FROM `sprint` WHERE `sup` IS NOT NULL GROUP BY `sup`"; $ret = mysql_query($q) or die(mysql_error()); while ($row = mysql_fetch_assoc($ret)) { $email_sec = $row['sup']; print "<option value=\"$email_sec\">Team $email_sec</option>"; } ?> </select> </td> </tr> <tr> <td>Message:<br /><textarea name=message wrap=physical onKeyDown="textCounter(this.form.message,this.form.remLen,143);" onKeyUp="textCounter(this.form.message,this.form.remLen,143);" cols="20" rows="6" id="comment" maxlength="143"></textarea><br /><input readonly type=text name=remLen size=3 maxlength=3 value="143" /> characters left </td> </tr> <tr> <td> <!-- Reply to email (If applicable):<br /> --><input name="email" type="hidden" id="email" size="20" value="reply@email.com"></td> </tr> <tr> <td valign="top"><font color="red" size="2"><b>Do not hit enter for a new line. This will give you less characters to use due to the text limits.</b></font><br /><input type="submit" name="Submit" value="Send"></td> </tr> </table> </form> </body> </html> <?php }; ?> I hope this helps. Now as of right now I know I am using multiple queries but its the only way I could break these choices down via my limited knowledge. Now my original issue right now is that I need one of the options to include two or more of the previous options listed. This is because the point of this script is for management at my work to be able to text a specific group by simply selecting them in the drop down. Because of this sometimes a group will overlap. For instance, they may want to send a text to leads and sups only. Then it could be Sales and sups only, etc. Feel free to ask any other questions.
  2. The data in all the rows are different. This whole thing is an email script basically. It lets you choose who to send a mass message to. Choices are, All Leads, All Sups, Techs, etc. And in this particular case my goal is to have one choice be Leads and Sups. To do that I need to join the data as one choice. In the DB each line is different. They are just labeled under "Dept" as what they are. I apologize if this makes no sense.
  3. I thought of a work around but I only want to use it if there is no way to do this. What I was going to do is add another row to the DB with a subtitle of L_S for leads and sups. Then add this title to all the leads and sups. Then query based on that row. The only issue is its another row that I do not think is needed. Let me know if that would be my best bet. Thanks
  4. No luck with that. My database structure is dept/sup/id/num/name/loc/all. Under dept there is about 10 different choices. T_LEAD and T_SUP being just two of them. For this option in my dropdown I want these two options to show as one option. I hope this makes sense. Feel free to ask any other question you may need. I once again appreciate any and all help I receive.
  5. Yes here I am again. Every time I learn something, a new thing pops up!! <?php $q = "SELECT `dept` FROM `sprint` WHERE dept='T_LEAD' OR dept='T_SUP' GROUP BY `dept`"; $ret = mysql_query($q) or die(mysql_error()); while ($row = mysql_fetch_assoc($ret)) { $email_sec = $row['dept']; print "<option value=\"$email_sec\">Leads and Sups</option>"; } ?> The above works but it shows up twice. I know it is because it is breaking it into the two groups I queried for (ie one shows up for T_LEAD and one shows up for T_SUP). How via php/mysql can I combine these two into one selection? Is it even possible? Thanks as always guys!
  6. Ok I did this: SELECT `dept` FROM `sprint` WHERE dept='T_LEAD' AND dept='T_SUP' GROUP BY `dept` But it doesn't work. I am such a noob I apologize.
  7. Another easy one that I cannot find. ARGH SELECT `dept` FROM `sprint` WHERE dept='T_LEAD' GROUP BY `dept` How do I add another thing with T_LEAD above? I want the WHERE dept= to look for T_LEAD and T_SUP. Comma does not work, nor space.
  8. Figured it out. I am an idiot. I did not have these items set as NULL. As you said, they were just empty. I fixed it. Thanks guys.
  9. There are only two items that are empty in this spot. I imported all the data from an excel sheet originally. In phpmyadmin this is set as "not null" with no default set if that matters.
  10. Just ran it in phpmyadmin and again the empty option shows. Somehow even though its empty, its not showing as NULL? Is that the only possibility left?
  11. Did that now and no error shows and the item remains. I am in the twilight zone I think. This is so simple but I am missing something.
  12. This should be working. Its something I actually had tried before but the option still shows. Here is my full code in case its needed for something else I am missing. <?php $q = "SELECT `sup` FROM `sprint` WHERE `sup` IS NOT NULL GROUP BY `sup`"; $ret = mysql_query($q); while ($row = mysql_fetch_assoc($ret)) { $email_sec = $row['sup']; print "<option value=\"$email_sec\">Team $email_sec</option>"; } ?>
  13. For some reason the null option still shows.
  14. With this code: select 'sup' from sprint GROUP BY 'sup'"; How do I edit it so that if 'sup' = NULL to ignore it?
  15. If its not possible just let me know. I know there are limitations somewhere.
  16. Thanks to a lot of help from this forum I am getting CLOSE to where I need to be. Here is my current issue. My code: <?php mysql_connect("localhost", "XXXX", "XXXX") or die(mysql_error()); mysql_select_db("TEXT_TOOL") or die(mysql_error()); if (!empty($_POST["email"])) { $q = "select `num` from sprint WHERE `dept` = '".mysql_real_escape_string($_POST["recip"])."'"; $ret = mysql_query($q); $emails = array(); while ($row = mysql_fetch_assoc($ret)) { $emails[] = $row['num'].'@messaging.sprintpcs.com'; } if ($emails) { $ToEmail = implode(', ', $emails); $EmailSubject = $_POST["subject"]."\r\n"; $mailheader = "From: ".$_POST["email"]."\r\n"; $MESSAGE_BODY = nl2br($_POST["message"]); // $MESSAGE_BODY .= ($_POST["auth"]); mail($ToEmail,$EmailSubject, $MESSAGE_BODY,$mailheader) or die ("Failure"); } ?> ---- <?php } else { ?> <form action="text_tool1.php" method="post"> <table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td valign="top"> Send To:<br /> <?php $q = "select `dept` from sprint GROUP BY `dept`"; $ret = mysql_query($q); print '<select name="recip">'; while ($row = mysql_fetch_assoc($ret)) { $email_sec = $row['dept']; print "<option value=\"$email_sec\">$email_sec</option>"; } ?> </select> </td> </tr> <tr> <td>Message:<br /><textarea name=message cols="20" rows="6" id="comment" maxlength="143"></textarea><br /> </td> </tr> <tr> <td> <input name="email" type="hidden" id="email" size="20" value="emailhere"></td> </tr> </table> </form> </body> </html> <?php }; ?> Right now it queries the DB and creates the choices in the dropdown based on groups of the "dept" row titles. This works flawlessly. But I now need to add more options in the same dropdown that combine some existing groups. How would I do this? Right now they show up as Tech, Sup, Bobs, Jims, etc. I now need to add more options that combine them like this: Tech/Sup, Bobs/Jims/Tech, Tech/Sup/Bobs How can I combine the existing options into a new option in the dropdown? Thank you as always!
  17. Genius! It worked so far flawlessly! Now all I need to figure out is how to add a choice for combinations. Thanks again! It is appreciated more than you know!
  18. Thanks for the help but I get a parse error on line 25. unexpected }
  19. I posted this elsewhere but I think it goes here since it relates to how to query Ok guys heres what I got! My current code is this: <?php if ($_POST["email"]<>'') { $ToEmail = $_POST["recip"]; $EmailSubject = $_POST["subject"]."\r\n"; $mailheader = "From: ".$_POST["email"]."\r\n"; $MESSAGE_BODY = nl2br($_POST["message"]); // $MESSAGE_BODY .= ($_POST["auth"]); mail($ToEmail,$EmailSubject, $MESSAGE_BODY,$mailheader) or die ("Failure"); ?> --- <?php } else { ?> <form action="text_tool.php" method="post"> <table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td valign="top"> Send To:<br /> <?php mysql_connect("localhost", "XXXXX", "XXXXX") or die(mysql_error()); mysql_select_db("TEXT_TOOL") or die(mysql_error()); $q = "select * from sprint"; $ret = mysql_query($q); print '<select name="recip">'; while ($row = mysql_fetch_assoc($ret)) { $email_addr = $row['num']; $email_sec = $row['dept']; $domain = '@messaging.sprintpcs.com'; $email_addr .= $domain; print "<option value=\"$email_addr\">$email_sec</option>"; } ?> </select> </td> </tr> <tr> <td>Message:<br /><textarea name=message cols="20" rows="6" id="comment" maxlength="143"></textarea><br /> </td> </tr> <tr> <td> <input name="email" type="hidden" id="email" size="20" value="reply@emailhere.com"></td> </tr> <tr> <td valign="top"><font color="red" size="2"><b>Do not hit enter for a new line. This will give you less characters to use due to the text limits.</b></font><br /><input type="submit" name="Submit" value="Send"></td> </tr> </table> </form> </body> </html> <?php }; ?> Right now it queries the DB and gives me select options of all the choices in row "dept". Shows up like this: <option value="EMAIL">Tech</option> <option value="EMAIL2">Tech</option> <option value="EMAIL3">Tech</option> <option value="EMAIL4">Sup</option> <option value="EMAIL5">Sup</option> This all works great. With the above I get all 270 of my entries listed separate. But what I need to do is have it query the same info but only display a main title (based on how its listed in the db under row:"dept") and have it email all of them. So what it SHOULD look like is: <option value="EMAIL, EMAIL2, EMAIL3">Tech</option> <option value="EMAIL4, EMAIL5">Sup</option> I hope this makes sense. There are over 10 options for the main titles. Such as Tech, Sup, Mgr, HR, etc. On top of the above I need some choices to overlap. Such as this: <option value="EMAIL, EMAIL2, EMAIL3">Tech</option> <option value="EMAIL4, EMAIL5">Sup</option> <option value="EMAIL, EMAIL2, EMAIL3, EMAIL4, EMAIL5">Techs and Sups</option> I am at a loss on how to do this. Any help is appreciated as always! You guys rock!
  20. Not sure if that does everything needed though. Like setting more groups which are combinations of other groups.
  21. Ok guys heres what I got! My current code is this: <?php if ($_POST["email"]<>'') { $ToEmail = $_POST["recip"]; $EmailSubject = $_POST["subject"]."\r\n"; $mailheader = "From: ".$_POST["email"]."\r\n"; $MESSAGE_BODY = nl2br($_POST["message"]); // $MESSAGE_BODY .= ($_POST["auth"]); mail($ToEmail,$EmailSubject, $MESSAGE_BODY,$mailheader) or die ("Failure"); ?> --- <?php } else { ?> <form action="text_tool.php" method="post"> <table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td valign="top"> Send To:<br /> <?php mysql_connect("localhost", "XXXXX", "XXXXX") or die(mysql_error()); mysql_select_db("TEXT_TOOL") or die(mysql_error()); $q = "select * from sprint"; $ret = mysql_query($q); print '<select name="recip">'; while ($row = mysql_fetch_assoc($ret)) { $email_addr = $row['num']; $email_sec = $row['dept']; $domain = '@messaging.sprintpcs.com'; $email_addr .= $domain; print "<option value=\"$email_addr\">$email_sec</option>"; } ?> </select> </td> </tr> <tr> <td>Message:<br /><textarea name=message cols="20" rows="6" id="comment" maxlength="143"></textarea><br /> </td> </tr> <tr> <td> <input name="email" type="hidden" id="email" size="20" value="reply@emailhere.com"></td> </tr> <tr> <td valign="top"><font color="red" size="2"><b>Do not hit enter for a new line. This will give you less characters to use due to the text limits.</b></font><br /><input type="submit" name="Submit" value="Send"></td> </tr> </table> </form> </body> </html> <?php }; ?> Right now it queries the DB and gives me select options of all the choices in row "dept". Shows up like this: <option value="EMAIL">Tech</option> <option value="EMAIL2">Tech</option> <option value="EMAIL3">Tech</option> <option value="EMAIL4">Sup</option> <option value="EMAIL5">Sup</option> This all works great. With the above I get all 270 of my entries listed separate. But what I need to do is have it query the same info but only display a main title (based on how its listed in the db under row:"dept") and have it email all of them. So what it SHOULD look like is: <option value="EMAIL, EMAIL2, EMAIL3">Tech</option> <option value="EMAIL4, EMAIL5">Sup</option> I hope this makes sense. There are over 10 options for the main titles. Such as Tech, Sup, Mgr, HR, etc. On top of the above I need some choices to overlap. Such as this: <option value="EMAIL, EMAIL2, EMAIL3">Tech</option> <option value="EMAIL4, EMAIL5">Sup</option> <option value="EMAIL, EMAIL2, EMAIL3, EMAIL4, EMAIL5">Techs and Sups</option> I am at a loss on how to do this. Any help is appreciated as always! You guys rock!
×
×
  • 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.