\n"); include("../header.shtml"); // Print the page title printf("

News Page

\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 contact the webmaster 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 contact the webmaster if this problem persists.'); while ($resultatenrij = mysql_fetch_row($resultatenreeks)) { // Put the results in a table, one table per result printf("\n"); printf("
cornerul %s cornerur %s
%s

\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("\n"); printf("
\n"); // Only show the option for the previous items on post-first-page if($begin>0 AND $aantalNewsItemsNo[0]>($maxShown*2)) {printf("Show items ".($begin-$maxShown+1) . " to " . ($begin) . "
\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("
Show items ".($begin+$maxShown+1) . " to " . min(($maxShown*2+$begin),$aantalNewsItemsNo[0]) . "
\n");} // Once we have shown all items, show the option to return to the first items else {printf("Show items ".(1) . " to " . ($maxShown) . "\n");} printf("\n"); } // Include a link to an XML RSS feed printf("

XML RSS icon

\n"); // Print the footer printf("\n"); include("../footer.php"); ?>