]> git.vanrenterghem.biz Git - www.vanrenterghem.biz.git/blob - News/index.php~
Baseline
[www.vanrenterghem.biz.git] / News / index.php~
1 <?php
2 printf("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>\n");
3 printf("<html>\n");
4 printf("<head>\n");
5 printf("<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-15' />\n");
6 printf("<meta name='author' content='Frederik Vanrenterghem' />\n");
7 printf("<meta name='Description' content='Personal homepage - news' />\n");
8 printf("<title>http://frederik.gotdns.org:1976 - News</title>\n");
9 printf("<link rel='stylesheet' type='text/css' href='/styles/main.css' />\n");
10 printf("<link rel='stylesheet' type='text/css' href='/styles/newspage.css' />\n");
11 printf("<link rel='stylesheet' type='text/css' href='/styles/header.css' />\n");
12 printf("</head>\n");
13 printf("<body>\n");
15 printf("<div class='thebody'>\n");
16 // Print the header
17 printf("<!--HEADER-->\n");
18 include("../header.shtml");
20 // Print the page title
21 printf("<h1>News Page</h1>\n\n");
23 // Define the variables
25 $dbserver="localhost";
26 $usernaam="frederik";
27 $paswoord="Fred1210";
28 $database="website";
29 $tabel="newsContent";
30 $maxShown=5;
32 if(!isset($begin)){$begin=0;}
34 // -- Table structure for table 'newsContent'
35 // --
36 //
37 // CREATE TABLE newsContent (
38 //   title varchar(40) default NULL,
39 //   date date default NULL,
40 //   body text
41 // )
43 // Connect to database
45 $db=mysql_connect($dbserver,$usernaam,$paswoord) or die ("Geen connectie met server");
46 mysql_select_db($database,$db) or die ("Database bestaat niet");
48 // Count the number of news items in the table
50 $aantalNewsItems=mysql_query("SELECT COUNT(*) from $tabel") 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.');
51 $aantalNewsItemsNo=mysql_fetch_row($aantalNewsItems);
54 // LIMIT x, y will limit the results to y rows, starting from x
56 $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.');
58 while ($resultatenrij = mysql_fetch_row($resultatenreeks)) {
60 // Put the results in a table, one table per result
61                 printf("<!--NEWSITEM-->\n");
62                 printf("<div class='newsitem'>\n");
63                 printf("<h1>%s</h1><h2><a href='/News/permalink.php?berichtID=%s'>%s</a></h2><p>%s</p>\n",
64                 $resultatenrij[0], $resultatenrij[1], $resultatenrij[1], $resultatenrij[2]);
65                 printf("</div>\n");
67 }
69 // Add some navigation - still to add option to modify maxShown
70 if($aantalNewsItemsNo[0]>$maxShown)
71 {
72         printf("<!--NAVIGATION-->\n");
73         printf("<div id='newsNav'>\n");
74         // Only show the option for the previous items on post-first-page
75         if($begin>0 AND $aantalNewsItemsNo[0]>($maxShown*2))
76          {printf("<H1><a href='index.php?begin=" . ($begin - $maxShown) . "'>Show items ".($begin-$maxShown+1) . " to " . ($begin) . "</a></h1>\n");}
77         // Show the next items, make sure not to mention a non-existing number of items with the min function
78         if($aantalNewsItemsNo[0]>($maxShown+$begin))
79          {printf("<h2><a href='index.php?begin=" .($begin+$maxShown)."'>Show items ".($begin+$maxShown+1) . " to " . min(($maxShown*2+$begin),$aantalNewsItemsNo[0]) . "</a></h2>\n");}
80         // Once we have shown all items, show the option to return to the first items
81         else
82          {printf("<h2><a href='index.php?begin=".(0)."'>Show items ".(1) . " to " . ($maxShown) . "</a></h2>\n");}
83         printf("<!--END NAVIGATION-->\n");
84         printf("</div>\n");
85 }
87 printf("<div id='RSS'>\n");
88 printf("<p><a href='/phppages/rss.php' title='Get the first 5 items of this News section in RSS XML format.'><img style='border:0' src='/Pics/xml.png' alt='XML RSS icon'></a></p>\n");
89 printf("</div>\n");
91 // Print the footer
92 printf("<div id='pagefooter'>\n");
93 include("../footer.php");
94 printf("</div>\n");
95 printf("</div>\n");
96 printf("</div>\n");
97 printf("</body>\n");
98 printf("</html>\n");
99 ?>