I wrote a php script to display per page news. Finally in theory because in practice it is the last news that appears on all my pages. It's several days that I try but in vain. I think my code is completely wrong, but will know.
Here is my code:
PHP Code:
<?php
mysql_connect ( "localhost", "********", "**********");
mysql_select_db ("**********");
$numberofmessagesperpage = 1 ;
$return = mysql_query ('SELECT COUNT (*) AS nb_messages FROM news');
$data = mysql_fetch_array ($return);
$numberofpages = $data ['nb_messages'];
if (isset ($_GET ['page']) && is_int ($_GET ['page']) && $_GET ['page']> 0 && $_GET [ 'Page'] <$numberofpages)
$Page = $_GET ['page'] - 1;
else
$Page = 0;
$return = mysql_query ('SELECT * FROM news ORDER BY id DESC LIMIT'. $Page.', 1');
while ($data = mysql_fetch_array ($return))
{
echo
'</p>
<div class="news">
<h3>. $Data ['title']. "
<em> the '. date ('d/m/Y to HHI', $data [timestamp']).' </em>
</H3>
<p> ';
$content = nl2br (stripslashes ($data ['content']));
echo $content. '</p> </div>';
}
echo 'Page:';
for ($i = 1; $i <= $numberofpages; $i++)
{
echo '<a href="index.php?page='. $i.'">'. $i. '</a>';
}
?>
If you have an idea of what will not, it would be nice to me to share your ideas
Bookmarks