mattm1712 Posted April 27, 2010 Share Posted April 27, 2010 hi i have tried to write a code where when someone replies to a post it emails the creator of the post notifying them they have a responce, but i have to select the name from the first table in my data base getting the name of who submited the post and then using the name select the email from another table, my tables look like this, users ------------------------------------------------------ name | email | pass | location and comments ------------------------------------------------------ submittedby | title | id | comment and my script is <?php include 'connect.inc'; $result4 = mysql_query("SELECT * FROM comments JOIN users on comments.submittedby=users.name WHERE comments.id=$t"); while($row = mysql_fetch_assoc($result4)); { $to = $row['email']; $subject = 'the subject'; $message = 'hello'; $headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); } ?> $t is define in the index ($t=$_GET['t'] page so i am am loooking at a post the url is http://www.moseleyengineering.co.uk/matt/index.php?variable=P2&p=1&t=200 can anyoe help? Link to comment https://forums.phpfreaks.com/topic/199957-notification-email-on-a-reply-to-a-post/ Share on other sites More sharing options...
monkeytooth Posted April 27, 2010 Share Posted April 27, 2010 do you have a table anywhere that associates the comments to the post that they pertain to? does that table have who the original poster was? If so, you have to query that table for the username or associated id for the user based on the post where the comment is being added, with that query you take the associated member ID and query your users table with it to get the email Link to comment https://forums.phpfreaks.com/topic/199957-notification-email-on-a-reply-to-a-post/#findComment-1049501 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.