// Copyright (C) 2000 Sylvain BAUDOIN // // The PHP3 code of this page may be redistributed and/or modified according to the terms of the GNU // General Public License, as it has been published by the Free Software Foundation (version 2 and // above) // // We retrieve the number of the page to be displaid as well as the other possible form parameters parse_str(getenv("QUERY_STRING")); if (($page == "") || ($page < 0)) { // Page numbering starts from 0 $page = 0; } // We prepare a connection to the MySQL server $host = "mysql_server"; $user = "database_user"; $password = "password"; // Connection mysql_connect($host, $user, $password) or die ("cannot connect to the database server"); mysql_select_db($bdd) or die ("cannot connect to the database"); // News to be displaid $query = "SELECT * FROM news ORDER BY Date DESC"; $result = mysql_query($query); // Number of messages $nbr = mysql_num_rows($result); // If we try to access a page beyond what the database contains, we show the last page if ($page*5+5 > $nbr) { $page = ($nbr-$nbr%5)/5; } // We retrieve news according to the page we want to access for($i = $page*5; ($i < $nbr) && ($i < $page*5+5); $i++) { if (! mysql_data_seek($result, $i)) { continue; } if (! $row = mysql_fetch_row($result)) { continue; } // We display news list($year, $month, $day) = split("-", substr($row[0], 0, 10)); $news = $row[1]; $source = $row[2]; $link = $row[3]; $title = $row[4]; echo "
| $title ($day/$month/$year) |
| \n";
echo " $news \n"; if ($lien != "") { echo " Link: $link\n";
}
echo " | \n
| source: $source |