By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,925 Members | 732 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,925 IT Pros & Developers. It's quick & easy.

storing email bcc: adresses from query result(s)

P: 3
I have a php page that pulls email addresses from a MSSQL database. I am trying to insert these addresses into the BCC: Outlook via a link.

my query is as follows:[php]$connect = mssql_connect(SERVER, LOGIN, PASS)
or die("Couldn't connect to SQL Server on SERVER");
$database = mssql_select_db(DBNAME,$connect)
or die("Couldn't open database $DBNAME");
$query = "SELECT Distinct ClcEmail
FROM ClientContact
WHERE Deleted = 0 AND ClcEmail IS NOT NULL";
$result = mssql_query($query);
$row = mssql_fetch_array($result);
while($row = mssql_fetch_array($result))
echo $row["ClcEmail"] . "; ";
}[/php]this lists all of the email addresses i want (about 700) and places a semi-colon and space between them. Any time I try to place this in an email link, it shows only 1 email address or sometimes none.

Apr 4 '08 #1
Share this Question
Share on Google+
6 Replies

Expert 2.5K+
P: 4,258
Welcome to Bytes!

Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

Apr 4 '08 #2

Expert 2.5K+
P: 4,258
But you do not show HOW you put these addresses inn the email link via PHP. Show that code (and show it within the appropriate code tags).

Apr 4 '08 #3

P: 3
Expand|Select|Wrap|Line Numbers
  1.     require_once('../../inc/inc.php');
  2.     $connect = mssql_connect(SERVER, LOGIN, PASS)
  3.     or die("Couldn't connect to SQL Server on SERVER"); 
  4.     $database = mssql_select_db(DBNAME,$connect)
  5.     or die("Couldn't open database DBNAME");
  6.     $query = "SELECT Distinct ClcEmail
  7.     FROM ClientContact 
  8.     WHERE Deleted = 0 AND ClcEmail IS NOT NULL"; 
  9.     $result = mssql_query($query);
  10.     $row = mssql_fetch_array($result);
  11.     while($row = mssql_fetch_array($result))
  12. {
  13.   $address = $row["ClcEmail"] . "; ";
  14. }    
and then my html looks like this..
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <a href="mailto:<?PHP echo $address?>.....</html>
I am trying first to only use the To:
This produces one email and it is the last one from my query.
Sorry for not reading the posting guidlines. hope its right now.
Apr 4 '08 #4

Expert 2.5K+
P: 4,258
When you want to make an address string like ";" etc. you must concatenate each result from the db row to the original string, like this[php]$address .= $row["ClcEmail"] . "; ";[/php]The way you do it now you continuously replace the string in $address with a new value.

Apr 4 '08 #5

P: 3
Thank you for your help.
Apr 7 '08 #6

Expert 2.5K+
P: 4,258
You are welcome. See you next time here.

Apr 7 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.