Jump to content


Return array from query that has two tables?

  • Please log in to reply
1 reply to this topic

#1 commandopress

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 23 April 2006 - 11:58 PM

I want to take the following code and add a query from an additional table.

$findauth_id="SELECT article_id,category_id,article_title,article_sum,article_body,article_res,article_key FROM articles WHERE status='F';";

$result = mysql_query($findauth_id);
if ($num_rows>0)
        while ($row= mysql_fetch_array($result, MYSQL_ASSOC))
          $article[$x][text]=strtolower($row[article_title])." ".strtolower($row[article_sum])." ".strtolower($row[article_body])." ".strtolower($row[article_res])." ".strtolower($row[article_key])." ".strtolower($row[pen_name]);
else {print "No articles to process"; exit;}

I want to add 'penname' from the table 'pen_name' to the $result array then as in the while statement use .strtolower($row[pen_name]) as an additional $article[$x][text] variable......

I have tried everything I can find online to get this to work, but it just breaks the code. I need to pull the pen_name entry into the array so that I can look it up and match it to keywords in a later function.

Any help or direction on this would be great!


#2 fenway

  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 24 April 2006 - 07:13 AM

You'll need to JOIN in the appropriate tables, and alias them to avoid collisions; after that, PHP has no idea what you've done, and everything should work as expected.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users