Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract the appropriate email addresses form database

Status
Not open for further replies.

mancroft

Programmer
Joined
Oct 26, 2002
Messages
267
Location
GB
Extract the appropriate email addresses form database

Confused over this, should be easy...

I am doing a basic newsletter sender.

A newsletter gets created and then sent to all those who have subscribed to the category so if the category is "Cat Breeding" and a person is signed up for that category then when I create a newsletter "Cat Breeding for Beginners" it is sent to all subscribers...

The code for the tables that I have done is below.

Question.... what is the PHP code needed to extract the appropriate email addresses from the database?
I.E.: only those who have signed up for that newsletter category.

Code:
TABLE newsletters

1 newsletterid int(4)  PRI  auto_increment 
2 newslettercategoryname varchar(100)     
3 newslettername varchar(100)     
4 newslettersubject varchar(200)     
5 newslettercontent text     
6 newslettercreatetime varchar(30)     
7 newsletterupdatetime varchar(30)     

TABLE subscribers

1 newsletterid int(4)  PRI 0  
2 subscriberid int(12)  PRI  auto_increment 
3 email varchar(50)  PRI   
4 subscribersignuptime varchar(30)     
5 subscriberupdatetime varchar(30)     
6 subscriberipaddress varchar(30)
 
Given a newsletter id, it would be to construct an SQL query like:

SELECT email FROM subscribers WHERE newsletterid = [the given newsletter id]

Then passing that to the database.

There is example code in the PHP online manual entry for mysql_fetch_array().



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top