Jump to content

customize script


mattm1712

Recommended Posts

i have been given this code which is wrong because it doent match my databases

but i have never seen this join function before

 

<?php

 

$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);

  }

?>

 

 

 

in my database i have 2 tables one called 'users' which has titles.    name email and pass  then i have another one called comments  with titles  id comments submittedby and title. 

 

i have the varible t$ which will be equal to the id in the comments table, from this i want to selct the submittedby name in the commens table, this wi be the same as the name in the users table, then i want to echo out the email adress.

 

can anyone help?

Link to comment
https://forums.phpfreaks.com/topic/199835-customize-script/
Share on other sites

Just needed to specify which fields you want.  (since you have to designate from which table while using a join)

 

SELECT comments.submittedby as submittedby, users.email as email FROM users JOIN comments on (comments.submittedby=users.name) WHERE comments.id=$t

Link to comment
https://forums.phpfreaks.com/topic/199835-customize-script/#findComment-1049026
Share on other sites

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.