Need compare code and send email code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bulgin
Forum Commoner
Posts: 29
Joined: Wed Feb 11, 2009 8:47 pm

Need compare code and send email code

Post by bulgin »

This should be simple enough but I'm a real newbie and could use some help.

table_a contains a list of unique_ids
table_b contains a list of unique_ids and email_address, name, message fields.

The unique_ids in table_a may or may not be the same as the unique_ids in table b.

I need a php script that I can run from a cron job that will:

enumerate through the unique_ids in table_a that have the field sent=0 and find their equal match in table_b.

If found:

mark the record in table_a as sent=1, pull the corresponding unique_id, email_address, name and message field from table_b that matched against unique_id from table_a and construct an email message from those fields and send it out the door.

If someone is quick at hand and sharp of mind perhaps they can shoot me the code I need to do this or point me in the right direction.

Thank you!
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Need compare code and send email code

Post by Benjamin »

So is this a project you bid on that you have no clue how to complete?
bulgin
Forum Commoner
Posts: 29
Joined: Wed Feb 11, 2009 8:47 pm

Re: Need compare code and send email code

Post by bulgin »

I wish, I wish that were the case and I was a good enough programmer to profit from such things. I'm a very, very new, newbie to php and trying to learn. No commercial interest here.

It's mostly the enumerating part of the query that I cannot figure out.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Need compare code and send email code

Post by Benjamin »

Generally what we do is assist others with their code when they get stuck. If you can post what you've got and let us know where you are stuck we are happy to help.

EDIT: You're probably looking for a database query?
bulgin
Forum Commoner
Posts: 29
Joined: Wed Feb 11, 2009 8:47 pm

Re: Need compare code and send email code

Post by bulgin »

thank you!

I will post it here and see what I can come up with.

Cheers!
bulgin
Forum Commoner
Posts: 29
Joined: Wed Feb 11, 2009 8:47 pm

Re: Need compare code and send email code

Post by bulgin »

my schema/data will be:

tablea
unique_id

tableb
unique_id
name
email
message

And the following code to get the matched records. I need help with generating an email from the returned results set.

$q = mysql_query("SELECT tablea.unique_id, tableb.name, tableb.email, tableb.message FROM tablea JOIN tableb ON tablea.unique_id=tableb.unique_id;");
while($r = mysql_fetch_assoc($q)) {
//do something with the row. This contains the name, email and message. I now need to output an email message with //php
}
Post Reply