Jump to content

Group query not list them seperate. And choose how to group.


Recommended Posts

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!

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.