<html> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-15"> <META NAME="Author" CONTENT="frederik.vanrenterghem@chello.be (Frederik Vanrenterghem)"> <META NAME="Description" CONTENT="Personal homepage - news"> <TITLE>http://frederik.gotdns.org:1976 - News</TITLE> <style type="text/css" media="screen"> <!-- a.menu:link { color: #fff; background: #000084; text-decoration: none; } a.menu:visited { color: #fff; background: #000084; text-decoration: none; } --> </style> </HEAD> <BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EF" VLINK="#55188A" ALINK="#FF0000"> <?php // Print the header printf("<!--HEADER-->\n"); include("../header.shtml"); // Print the page title printf("<BR><H1>News Page</H1>\n\n"); // Define the variables $dbserver="localhost"; $usernaam="frederik"; $paswoord="Fred1210"; $database="website"; $tabel="newsContent"; $maxShown=5; if(!isset($begin)){$begin=0;} if(ereg('[^0-9]', $begin)) { die ('Invalid input format in URL. Please <a href="/About/index.shtml">contact the webmaster</a> if this problem persists.'); } // -- Table structure for table 'newsContent' // -- // // CREATE TABLE newsContent ( // title varchar(40) default NULL, // date date default NULL, // body text // ) // Connect to database $db=mysql_connect($dbserver,$usernaam,$paswoord) or die ("Geen connectie met server"); mysql_select_db($database,$db) or die ("Database bestaat niet"); // Count the number of news items in the table $aantalNewsItems=mysql_query("SELECT COUNT(*) from $tabel"); $aantalNewsItemsNo=mysql_fetch_row($aantalNewsItems); // LIMIT x, y will limit the results to y rows, starting from x $resultatenreeks=mysql_query("SELECT * FROM $tabel ORDER BY date DESC LIMIT $begin, $maxShown") or die ('An error occured while retrieving data from the database. Please <a href="/About/index.shtml">contact the webmaster</a> if this problem persists.'); while ($resultatenrij = mysql_fetch_row($resultatenreeks)) { // Put the results in a table, one table per result printf("<!--NEWSITEM-->\n"); printf("<table border='0' cellpadding='0' cellspacing='0' width='100%%' summary=''><tr><td><table bgcolor='#000084' border='0' cellpadding='0' cellspacing='0' width='100%%' summary=''> <tr><td valign='top'><img src='/Pics/newsitem_ul.png' align='left' border='0' hspace='0' vspace='0' alt='cornerul' width='16' height='16'><font color=white><B> %s</B></font> </td><td align='right' valign='top'><img src='/Pics/newsitem_ur.png' align='right' border='0' hspace='0' vspace='0' alt='cornerur' width='16' height='16'><font color=white><B> <A HREF='/News/permalink.php?berichtID=%s 'class='menu'>%s </A> </B></font></td></tr></table></td></tr><tr><td> %s <BR><BR></td></tr></table>\n\n", $resultatenrij[0], $resultatenrij[1], $resultatenrij[1], $resultatenrij[2]); } // Add some navigation - still to add option to modify maxShown if($aantalNewsItemsNo[0]>$maxShown) { printf("<!--NAVIGATION-->\n"); printf("<table border='0' cellpadding='0' cellspacing='0' width='100%%' summary=''><tr><td align='left'>\n"); // Only show the option for the previous items on post-first-page if($begin>0 AND $aantalNewsItemsNo[0]>($maxShown*2)) {printf("<a href='index.php?begin=" . ($begin - $maxShown) . "'>Show items ".($begin-$maxShown+1) . " to " . ($begin) . "</a><BR>\n");} // Show the next items, make sure not to mention a non-existing number of items with the min function if($aantalNewsItemsNo[0]>($maxShown+$begin)) {printf("</TD><TD align='right'><a href='index.php?begin=" .($begin+$maxShown)."'>Show items ".($begin+$maxShown+1) . " to " . min(($maxShown*2+$begin),$aantalNewsItemsNo[0]) . "</a></td></tr></table>\n");} // Once we have shown all items, show the option to return to the first items else {printf("</TD><TD align='right'><a href='index.php?begin=".(0)."'>Show items ".(1) . " to " . ($maxShown) . "</a></td></tr></table>\n");} printf("<!--END NAVIGATION-->\n"); } // Include a link to an XML RSS feed printf("<P><A HREF='/phppages/rss.php' title='Get the first 10 items of this News section in RSS XML format.'><IMG SRC='/Pics/xml.png' BORDER=0 ALT='XML RSS icon'></A></P>\n"); // Print the footer printf("<!--FOOTER-->\n"); include("../footer.php"); ?> </BODY> </HTML>