Jump to content


This topic is now archived and is closed to further replies.


Return array from query that has two tables?

Recommended Posts

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!


Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.