Jump to content

[SOLVED] sql join query//


runnerjp

Recommended Posts

this is new to me so here it goes...

 

$query = "SELECT fe.*, u.email, u.id FROM forum_email as fe
LEFT JOIN users as u on u.ID = fe.id
WHERE topic_id = '".$forumpostid."' AND fe.user_id != '".$id."' AND mailed='n'";
$res = @mysql_query($query) or die ("sendNotification query fails :".mysql_error());

 

theres my query but i keep getting told im getting the data from the wrong tables... this is where im puliing it from

 

table = users

 

ID

 

and from my other one

 

table = forum_emails

 

user_id

topic_id

mailed

 

 

so form that where have i gone wrong :S

Link to comment
https://forums.phpfreaks.com/topic/132733-solved-sql-join-query/
Share on other sites

sorry fixed that... but now for sending emails i get

 

Warning: Invalid argument supplied for foreach() in /home/runningp/public_html/members/include/reply.php on line 75

 

<?


                $query = "SELECT fe.*, u.email, u.id FROM forum_email fe
LEFT JOIN users as u on u.ID = fe.user_id
WHERE topic_id = '".$forumpostid."' AND fe.user_id != '".$id."' AND mailed='n'";
$res = @mysql_query($query) or die ("sendNotification query fails :".mysql_error());

//nobody wants an email, stop now
if(count($id) == 0):
return;
endif;

foreach($id as $value) {
//define the receiver of the email
$to = $userinfo['email'];
//define the subject of the email
$subject = 'Test email';
//define the message to be sent. Each line should be separated with \n
$message = "im sending an email too myself.";
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: [email protected]\r\nReply-To: [email protected]";
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" 
echo $mail_sent ? "Mail sent" : "Mail failed";
}?>

Archived

This topic is now archived and is closed to further replies.

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