I'll start by publishing my code:
// query article
$query1 = "SELECT page_title,author_id FROM articles WHERE category = 'fiction'";
$mysql_result1 = mysql_query ($query1)
or die ("Query '$query1' failed with error message: \"" . mysql_error () . '"');
$fiction_articles = mysql_fetch_assoc($mysql_result1);
// query author
$auth_result = &$fiction_articles['author_id'];
$query2 = "SELECT author FROM authors WHERE author_id = '$auth_result'";
$mysql_result2 = mysql_query ($query2)
or die ("Query '$query2' failed with error message: \"" . mysql_error () . '"');
$auth_row = mysql_fetch_assoc($mysql_result2);
// Parameters
$fiction_page_title = $fiction_articles['page_title'];
$fiction_author = $auth_row['author'];
// Print
$row = 0;
while($row = mysql_fetch_assoc($mysql_result1))
{
echo ' <li>' . $fiction_author . ': "' . $row['page_title'] . '"</li>';
$row++;
}
Now, I have to admit, I know some PHP and MySQL stuff, but I'm still a-learning.
So, I basically have two tables in my database. "articles" and "authors". In this specific case I have to grab 'page_title' and 'author_id' from "articles" and 'author' from "authors". Why the last bit? Well, 'author_ids' in "articles" are set in code (so, for example, 'w001') and the corresponding author information is stored in "authors".
Now, I want to create an archive list of all the entries in "articles" which have as 'category' fiction.
Problem is, it's not working. It grabs a random fiction entry to use and processes that, but 1) only does it once and then stops and 2) doesn't connect the 'author_ids'.
I'm doing a lot wrong in this code, but I've changed it so often after having found a new way to do (found on the web) that it has become foggy.
Help?