commandopress Posted April 23, 2006 Share Posted April 23, 2006 I want to take the following code and add a query from an additional table. [code]$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);$x=0;$num_rows=mysql_num_rows($result);if ($num_rows>0) { while ($row= mysql_fetch_array($result, MYSQL_ASSOC)) { $article[$x][id]=$row[article_id]; $article[$x][categid]=$row[category_id]; $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]); $x++; } }else {print "No articles to process"; exit;}[/code]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!Rick Quote Link to comment https://forums.phpfreaks.com/topic/8212-return-array-from-query-that-has-two-tables/ Share on other sites More sharing options...
fenway Posted April 24, 2006 Share Posted April 24, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/8212-return-array-from-query-that-has-two-tables/#findComment-30005 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.