<? if($_GET['archive'] == 'yes'){ $newsSql = "SELECT * FROM news"; }else{ $newsSql = 'SELECT * FROM news LIMIT 6'; } $newsSql = mysql_query($newsSql); if(mysql_num_rows($newsSql) == 0){ echo 'There are no news articles'; }else{ $writeDiv = true; echo '<table width="100%" border="0" cellspacing="0" cellpadding="0" background="images/news.gif" style="background-position:left; background-repeat:no-repeat;">'; while($newsArray = mysql_fetch_array($newsSql)){ //get category information $cat = mysql_query('SELECT * newscategory WHERE id = '.$newsArray['category']); $cat = mysql_fetch_array($cat); $catImage = $cat['image']; $cat = $cat['name']; //get staf information $staff = mysql_query('SELECT * staff WHERE id = '.$newsArray['staffid']); $staff = mysql_fetch_array($staff); $staffEmail = $staff['email']; $staff = $staff['username']; //modify date format $date = convertDate($newsArray['date']); echo' <tr> <th colspan="2" scope="col"><div align="left">'.$cat.'</div></th> </tr> <tr> <td colspan="2"></td> </tr> <tr> <td width="72" height="72" rowspan="2" align="left" valign="top">'.$catImage.'</td> <td>'.$title.'</td> </tr> <tr> <td>'.$body.'</td> </tr> <tr> <td colspan="2"><div align="right" class="smallText">Posted by <a href="mailto:'.$staffEmail.'">'.$staff.'</a> on '.$date.'</div></td> </tr>'; if($writeDiv == true){ echo '<div>'; } $writeDiv = false; }//end while loop echo '</div> </table>'; if(mysql_num_rows($newsSql) > 1){ echo '<div align="center"><label><a href="javascript:expandAndHide();">Expand</a></label> <a href="index.php?page=default&archive=yes">Archive</a></div>'; } ?>
if(mysql_num_rows($newsSql) == 0){ echo 'There are no news articles'; }else{