Forums

Retrive User Article Email from Database

solfri 14 Feb, 2013
Hi everybody
i need a help

im trying to call the email of user have write article from database.

in custom html/php i have put this
<?php
$database =& JFactory::getDBO();
$query = "SELECT * FROM #__users c JOIN #__content  u ON c.id  =  u.id";
$database->setQuery( $query );
$useremail = $database->loadObject();
echo $useremail->email;
?>


But the field display the email of user connected not the email of the user have created the article.
Somebody can help me?

Thanks in advance
GreyHead 15 Feb, 2013
Hi solfri,

Your MySQL query needs to be much more sepcific, at present it will return many, many records, not just a single email.

Bob
Max_admin 17 Feb, 2013
Hi,

The query is very vague and the join condition is supposed to be wrong as well, If you know the article id then you should also use it:

$query = "SELECT * FROM #__users AS u LEFT JOIN #__content AS c ON c.user_id = u.id WHERE c.id='ARTICLE_ID'";


Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.