I have this code, below that displays all the news items in the database. What I am trying to do is setup pagination so that only 10 display per page. I've looked and haven't found anything that I can understand well enough to do...
<?
// includes
include("xxx.php");
// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
// generate and execute query
$query = "SELECT ID, headline, date_format(date, '%b.%e.%Y')as todays_date FROM news ORDER BY date DESC";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
// if records present
if (mysql_num_rows($result) > 0)
{
// iterate through resultset
// print article titles
while($row = mysql_fetch_object($result))
{
?>
<a href="news_detail.php?ID=<? echo$row->ID; ?>"><strong><? echo$row->headline; ?></strong></a><br>
<?
}
}
// if no records present
// display message
else
{
?>
<li><b>No news items currently available.
<?
}
// close database connection
mysql_close($connection);
?>