hi again. i just got a pagination code here by batman. but i have these problems.
this is the complete code:
$limit = 8;
$query_count = "SELECT * FROM thisday WHERE
(EVENTYEAR LIKE '%$EVENTYEAR%'
AND EVENTDATE LIKE '%$EVENTDATE%')
ORDER BY EVENTDATE DESC ";
$result_count = mysql_query($query_count);
$totalrows = mysql_num_rows($result_count);
if(empty($page))
$page = 1;
$limitvalue = $page * $limit - ($limit);
$query = "SELECT * FROM thisday WHERE
(EVENTYEAR LIKE '%$EVENTYEAR%'
AND EVENTDATE LIKE '%$EVENTDATE%')
ORDER BY EVENTDATE DESC
LIMIT $limitvalue, $limit ";
$result = mysql_query($query) or die("Error: " . mysql_error());
$count_result = mysql_num_rows($result);
// Display links at the top to indicate current page and number of pages displayed
$numofpages = ceil($totalrows / $limit);
echo"<br><p><b>$totalrows</b> result(s) for: \"$search\"</p>";
$from=$limit*$page-$limit+1;
$to=$from + $count_result-1;
// start 123 next>> table
echo "<table align=\"center\" width=\"90%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr><td width=\"50%\" bgcolor=\"$bg_colour\" align=\"left\">";if($numofpages>1){echo"Showing: $from - $to</td><td width=\"50%\" bgcolor=\"$bg_colour\" align=\"right\"><b>Go to page:</b> ";}
// display previous link if page is not 1
if($page != 1){
$pageprev = $page - 1;
echo("<a href=\"$PHP_SELF?page=$pageprev&search=$search\"><< PREV</a> ");
}
// display page nos if not 1
for($i = 1; $i <= $numofpages; $i++){
if($numofpages>1){
if($i == $page)
echo(" ".$i." ");
else
echo(" <a href=\"$PHP_SELF?page=$i&search=$search\">$i</a> ");
}}
// display next page link if there is more than one
if(($totalrows - ($limit * $page)) > 0){
$pagenext = $page + 1;
echo("<a href=\"$PHP_SELF?page=$pagenext&search=$search\">NEXT >></a>");
}
// end 123 next>> table
echo"</td></tr></table><br>";
if (($row["DAY"]) == "00")
{
echo "<table bgcolor=#FFFEEF border=0 cellpadding=2 cellspacing=0 style=border-collapse: collapse bordercolor=#111111 width=100%>
<tr><td align=left width=20% valign=top><b><font face=Verdana size=2 color=#800080><li>{$row['EVENTYEAR']}-{$row['MONTH']}</font></b></td>
<td align=justify width=80% valign=top><font face=Verdana size=2 color=#000000>{$row['EVENTTEXT']}</td></table>";
}
else
{
echo "<table bgcolor=#FFFEEF border=0 cellpadding=2 cellspacing=0 style=border-collapse: collapse bordercolor=#111111 width=100%>
<tr><td align=left width=20% valign=top><b><font face=Verdana size=2 color=#800080><li>{$row['EVENTDATE']}</font></b></td>
<td align=justify width=80% valign=top><font face=Verdana size=2 color=#000000>{$row['EVENTTEXT']}</td></table>";
}
echo ("<p>");
echo ("<p>");
?>
when i do a search it correctly displays, the number or records found but it shows something like
and the records are not shown! which is the part of the code.
if (($row["DAY"]) == "00")
{
echo "<table bgcolor=#FFFEEF border=0 cellpadding=2 cellspacing=0 style=border-collapse: collapse bordercolor=#111111 width=100%>
<tr><td align=left width=20% valign=top><b><font face=Verdana size=2 color=#800080><li>{$row['EVENTYEAR']}-{$row['MONTH']}</font></b></td>
<td align=justify width=80% valign=top><font face=Verdana size=2 color=#000000>{$row['EVENTTEXT']}</td></table>";
}
else
{
echo "<table bgcolor=#FFFEEF border=0 cellpadding=2 cellspacing=0 style=border-collapse: collapse bordercolor=#111111 width=100%>
<tr><td align=left width=20% valign=top><b><font face=Verdana size=2 color=#800080><li>{$row['EVENTDATE']}</font></b></td>
<td align=justify width=80% valign=top><font face=Verdana size=2 color=#000000>{$row['EVENTTEXT']}</td></table>";
}
and also, when i try to press the next button, if goes to count all the data on the database but never showing the data! what could be wrong?
thanks.