I'm running PHP 5.28 on a localhost Apache install, and one of my current projects is a database-driven site which has a TV guide and showbiz news (the one that this pagination script is for!).
Most of the site is database-driven without using a CMS, since it is updated weekly, rather than daily.
So far the site is working well (apart from pagination, which is my main problem).
I am using this site as a testbed for now, if it works I will re-use the template for some of my other projects.
This is the code for the episode on-air:
<?PHP
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect("localhost","root","PASSWORD");
//select which database you want to edit
mysql_select_db("housemdepisodes");
// Select only results for today and future
$result = mysql_query("SELECT * FROM `epdata` WHERE `expiration`
=NOW() ORDER BY `expiration` ASC LIMIT 20");
while($r = mysql_fetch_array($result)) {
$programme = $r["programme"];
$channel = $r["channel"];
$airdate = strtotime($r['airdate']);
$expiration = strtotime($r['expiration']);
$episode = $r["episode"];
$setreminder = $r["setreminder"];
$now = time();
if(date('Y-m-d') == date('Y-m-d', $airdate)) {
// Same date, show only time
$dateFormat = 'g:ia';
} elseif(date('Y') == date('Y', $airdate)) {
// Same year, show date without year
$dateFormat = 'F jS - g:ia';
} else {
// Other cases, show full date
$dateFormat = 'F jS, Y - g:ia';
}
$airdateFormatted = date($dateFormat, $airdate);
echo "<tr><td><b>$programme</b></td><td>showing on $channel</td>";
echo "<td>$airdateFormatted</td><td>$episode</td><td>$setreminder</td></tr>";
}
?>
That above code works, and generates 20 records per page in the guide, but with my pagination, I am trying to get code like this with the 20 records:
(I have used the quote tag here rather than PHP code, to avoid people having to scroll across the screen to read it!)
<div class="indented searchFooter" style="border-top: 1px solid rgb(207, 214, 233);"><table summary="" class="stNoMargins" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="tinyText stNoMargins"><div class="btnContainer"><ul><li><a class="smBtnSel" href="tvguide.php?page=1">1</a></li><li><a class="smBtn" href="tvguide.php?page=2">2</a></li><li><a class="smBtn" href="tvguide.php?page=2" title="Next Page">»»</a></li></ul></div></td><td class="smalltext"> Total <strong>2</strong> pages </td>
and this for any subsequent pages in the pagination script (this example is for page 2):
<div class="indented searchFooter" style="border-top: 1px solid rgb(207, 214, 233);"><table summary="" class="stNoMargins" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="tinyText stNoMargins"><div class="btnContainer"><ul><li><a class="smBtn" href="http://library.digiguide.com/lib/programmenextshowing/12578&hPage=1" title="Previous Page">«</a></li><li><a class="smBtn" href="http://library.digiguide.com/lib/programmenextshowing/12578&hPage=1">1</a></li><li><a indepth="true" class="smBtnSel" href="index.html">2</a></li></ul></div></td><td class="smalltext"> Total <strong>2</strong> pages </td>
Basically, it would display the following:
(that's an example of my code above, as it currently looks, still undergoing CSS modification now!)
Is there any way I could do this with a pagination script, keeping it within the div classes specified in my CSS?
I have tried a few scripts off Google, but they did not suit this particular bit of the site.
If anyone could give me some advice on how to get a pagination script to work correctly, using the CSS div code above, it would be much appreciated.