Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2009
    Posts
    2

    Red face Unanswered: Get 2 database tables assign to one output

    Hi,

    I have 2 database tables:
    XXXX_user
    XXXX_userpoints

    From XXXX_user I need:
    id, username, gender, gender, floor(period_diff(extract(year_month from NOW()),extract(year_month from birth_date))/12) as age, allow_viewonline, city, country, state_province

    From XXXX_userpoints I need
    id, points

    I am using PHP for coding.

    Now I need to get data from both of them and assign them the same output
    For example

    $TopList = SELECT GET BOTH database tables
    Then:
    PHP Code:
    foreach ($TopList as $row) { 
    It is possible to get both at the same time under $TopList ?
    If not can I get them as 2 separate ones then assign them both as $row if so how?

    Thanks,
    Big-Gaz

  2. #2
    Join Date
    Aug 2009
    Posts
    2
    Would this do it
    ut. = user table
    upt. = user points table

    $TopList = $osDB->getAll ('SELECT ut.id as id, ut.username as username, ut.gender as gender, ut.allow_viewonline as allow_viewonline, ut.city as city, ut.country as country, ut.state_province as state_province, ut.floor(period_diff(extract(year_month from NOW()),extract(year_month from birth_date))/12) as age, upt.points as points FROM ! as ut ! as upt WHERE ut.status = ? ORDER BY points DESC LIMIT 10', array(USER_TABLE, USER_POINTS_TABLE, Active));

    Thanks,
    Big-Gaz

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •