SEVIZ Posted April 18, 2009 Share Posted April 18, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/154643-group-query-not-list-them-seperate-and-choose-how-to-group/ Share on other sites More sharing options...
fenway Posted April 20, 2009 Share Posted April 20, 2009 Well, the first part can be accomplished with group-concat. Quote Link to comment https://forums.phpfreaks.com/topic/154643-group-query-not-list-them-seperate-and-choose-how-to-group/#findComment-814572 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.