Add to delicious
Add to technorati
Add to technorati
Digg it
furl
Yahoo

Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorJared
    • CommentTimeJan 4th 2009
     # 1

    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!

    • CommentAuthornikolar
    • CommentTimeJan 4th 2009 edited
     # 2

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

    • CommentAuthorFSX
    • CommentTimeJan 5th 2009
     # 3

    You should learn SQL and learn to use "joins". :)

    • CommentAuthorJared
    • CommentTimeJan 5th 2009
     # 4

    Thanks guys! Will be looking into "joins".

  1.  # 5


    $getAccounts = $Db->select("accounts");
    while($account = $Db->fetch_assoc($getAccounts)
    {
    echo $account['title'];
    echo $account['email'];
    echo $account['website'];
    echo $account['username'];
    }

    • CommentAuthorjose
    • CommentTimeOct 6th 2009 edited
     # 6

    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'];

    }