I have two tables in a mysql databse 'topics' and 'horizons' for a newsletter . Topics contains 'issue' 'list' 'topic' 'link' and 'category' columns. Horizons has 'issue' 'month' 'pdf_name' 'file_size' and 'year' columns. What I'm trying to do is to have the Issue number and date with a link to both html and pdf versions, but also have the topics from each newsletter alongside. At the moment I have everything working can't find a way of looping through the topics and placing them alongside the associated issue without looping multiple versions of the issue, or just repeating the same topic. Do I need to use another nested array for the topic, or create another mysql query, or can I use something like while(), foreach() or for() to do this with the query I have?
$db = mysql_pconnect("localhost", "username","password");
echo "Error: Could not connect to database. Please try again later.";
// get results from horizon and topic tables
$query = "select * from topics, horizons where topics.issue = horizons.issue order by topics.issue desc";
$result = mysql_query($query) or die(mysql_error());
$num_results = mysql_num_rows($result);
$row = mysql_fetch_array($result);