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? I would
PHP Code:
<?php
$db = mysql_pconnect("localhost", "username","password");
if (!$db)
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}
// get results from horizon and topic tables
mysql_select_db("aamsurveys_com_au");
$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);
$issue=$row[0];
$topic=$row[2];
$link=$row[3];
$category=$row[4];
$month=$row[6];
$pdfname=$row[7];
$filesize=$row[8];
$year=$row[9];
// add topics and links etc
echo "
<tr align='left' valign='left' >
<td height='26' colspan='5' > </td>
</tr>
<tr align='left' valign='left' >
<td width='200'align='left' >
<font face='arial' size='2' color='#000099'>
Issue ".$issue." $month $filesize</font>
<p><a href='issue".$issue."/index.html'>
<font face='arial' size='1' color='#660000'>View<b>HTML </b></font></a>
</p>
<p>
<a href='issue".$issue."/".$link."'>
<font face='arial' size='1' color='#660000'>
View <b> PDF ".$filesize."k </b></font></a>
</p>
</font>
</td>
<tr>
<td colspan='2' valign='top'>
<div align='middle'>
<a href='".$link."'>
<font face='arial' size='2' color='#660000'><b>".$topic." </b></font></a>
</div></td>
<td > </td>
</tr>
<tr>
<td height='22'> </td>
<td > </td>
<td > </td>
<td > </td>
</tr>
";
// build headings and tables
echo"
<tr>
<td colspan='5'>
<div align='right'>
<a href='#top'>
<img src='images/totop.gif' width='100' height='23' border='0' class='totop'></a>
</div>
</td>
</tr>
<tr bgcolor='#aea981'>
<td colspan='5'>
<div align='left'>
<a href='horizonstopic.htm'>
<font face='arial' size='2' color='#000099'>
View by Topic</font></a>
</div>
</td>
</tr>
</table>
";
?>
--
edited in hopes to make it a little more readable - too much horizontal scrolling...
-bdl