Wondering if someone could give some sample code for retrieving the authors name from the accounts table instead of the id of the author?
Thanks!
I'm new to PE and a little rusty with SQL but try replacing $getFAQs = $Db->select(...); with something like this:
$posts = $Db->query("
select blog.title_txt, accounts.title_txt, blog.body_txtbox
from blog, accounts
where blog.accounts_rel = accounts_id
");
You should learn SQL and learn to use "joins". :)
Thanks guys! Will be looking into "joins".
$getAccounts = $Db->select("accounts");
while($account = $Db->fetch_assoc($getAccounts)
{
echo $account['title'];
echo $account['email'];
echo $account['website'];
echo $account['username'];
}
I know this is old but this might help someone else out. Good luck
$foo = $Db->query("
SELECT
blog.*,
accounts.title AS display_name
FROM blog
JOIN accounts ON blog.account_rel = accounts.id
");
while($bar = $Db->fetch_assoc($foo))
{
echo $bar['display_name'];
}
1 to 6 of 6