\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("http://frederik.gotdns.org:1976 - News\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("
\n"); // Print the header printf("\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;} // -- 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") or die ('An error occured while retrieving data from the database. Please contact the webmaster if this problem persists.'); $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("
\n"); printf("

%s

%s

%s

\n", $resultatenrij[0], $resultatenrij[1], $resultatenrij[1], $resultatenrij[2]); printf("
\n"); } // 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"); printf("
\n"); } printf("
\n"); printf("

XML RSS icon

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