code help - pagination


Posted on 16th Feb 2014 07:03 pm by admin

Hi all, I have this code, basically a user logs into my site and they get this page.

The problem I have is that the pagination isn't working, and I can figure out why. I dont get any errors.

Can you help please. If you need any more info, just shout. Ta muchly

Code: <?php
include("includes/dbconnect120-gem.php");
include("includes/db_auth_hp.php");
include("includes/functions.php");
$username = $result['username'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/templ8t.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/layout.css" rel="stylesheet" type="text/css" />
<link href="css/text.css" rel="stylesheet" type="text/css" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<script language="javascript" type="text/javascript">
<!--
function showhide(id) {
if(document.getElementById(id).style.display == 'none') {
document.getElementById(id).style.display = 'block';
} else {
document.getElementById(id).style.display = 'none';
}
}
-->
</script
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
.H2 {
font-size: x-large;
font-family: Arial, Helvetica, sans-serif;
background-color: #FFFF00;
}
.link {color: #FFFF33}
-->
</style>


</head>
<body>
<div class="wrapper">
<div class="header">
</div>
<div class="body">
<!-- InstanceBeginEditable name="bodytext" -->
Hello, <?php echo ucwords($username); ?> you are now logged in.

<?php

// find out how many rows are in the table
$sql = "SELECT COUNT(*) FROM articles";
$result = mysql_query($sql) or trigger_error("SQL", E_USER_ERROR);
$r = mysql_fetch_row($result);
$numrows = $r[0];

// number of rows to show per page
$rowsperpage = 1;
// find out total pages
$totalpages = ceil($numrows / $rowsperpage);

// get the current page or set a default
if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
// cast var as int
$currentpage = (int) $_GET['currentpage'];
} else {
// default page num
$currentpage = 1;
} // end if

// if current page is greater than total pages...
if ($currentpage > $totalpages) {
// set current page to last page
$currentpage = $totalpages;
} // end if
// if current page is less than first page...
if ($currentpage < 1) {
// set current page to first page
$currentpage = 1;
} // end if

// the offset of the list, based on current page
$offset = ($currentpage - 1) * $rowsperpage;

//Gets news.
$sql = "SELECT * FROM articles ORDER BY ID DESC";
$result = mysql_query($sql);
//Displays the results.
while($row = mysql_fetch_array($result)){
$news_title = nl2br($row['Title']);
$news_subtitle = nl2br($row['SubTitle']);
$news_post = nl2br($row['Article']);
$post_id = $row['ID'];

echo $news_title;?>

<?php echo $news_subtitle; ?>

<?php echo $news_post; ?>


<!-- END DISPLAY NEWS -->

<?php
$csql = "SELECT comments.tstamp, login.username, comments.post
FROM comments
LEFT JOIN login
ON comments.userid = login.userid
WHERE comments.articleid = $post_id
ORDER BY comments.postid DESC";

$cquery = mysql_query($csql);
$ccount = mysql_num_rows($cquery);
if($ccount == 0) {
$comments_number = '<a href="comment.php?post='.$post_id.'" target="_self">No Comments</a>';
} else {
$comments_number = '<a href="#coms'.$post_id.'" onclick="showhide('c'.$post_id.'');">Comments('.$ccount.')</a>';
}
?>

<p class="right"><?php echo $comments_number; ?><a name="coms<?php echo $post_id; ?>"></a>&nbsp;&nbsp;&nbsp;</p>
<div style="display:none" id="<?php echo 'c'.$post_id; ?>" >
<?php
if($ccount != 0) {

while($crow = mysql_fetch_array($cquery)) {
$ctime = $crow['tstamp'];
$cusername = ucwords($crow['username']);
$cmessage = $crow['post'];
echo "<hr />n";
echo '<p><span class="bold">'.$cusername.':</span> '.nl2br($cmessage)."n";
echo '<br /><span class="bold">Posted: </span>';
if(timeago($ctime) == '') {
echo "Just.n";
}
elseif(strlen(timeago($ctime)) < 16) {
echo str_replace('and ', '', timeago($ctime)).'ago.</p>'."n";
} else {
echo timeago($ctime).'ago.</p>'."n";
}
}

$more = 'Leave a Comment';

echo '<p class="right"><a href="comment.php?post='.$post_id.'" target="_self">'.$more.'</a></p>';
}
?>
</div>
<?php
} // end while

/****** build the pagination links ******/
// range of num links to show
$range = 4;

// if not on page 1, don't show back links
if ($currentpage > 1) {
// show << link to go back to page 1
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> ";
// get previous page num
$prevpage = $currentpage - 1;
// show < link to go back to 1 page
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> ";
} // end if

// loop to show links to range of pages around current page
for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
// if it's a valid page number...
if (($x > 0) && ($x <= $totalpages)) {
// if we're on current page...
if ($x == $currentpage) {
// 'highlight' it but don't make a link
echo " [<b>$x</b>] ";
// if not current page...
} else {
// make it a link
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> ";
} // end else
} // end if
} // end for

// if not on last page, show forward and last page links
if ($currentpage != $totalpages) {
// get next page
$nextpage = $currentpage + 1;
// echo forward link for next page
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> ";
// echo forward link for lastpage
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> ";
} // end if
/****** end build pagination links ******/
?>





<!-- InstanceEndEditable --> </div>
<div class="sidebar">
<!-- MENU -->
<BR><?php
include "includes/menujs.js";
include "includes/menucss.css";
include "includes/menu.html";
?>
</p>
<p>

<!-- InstanceBeginEditable name="sidebar" -->
<div class="sidebartitle">
Latest News</div>


<div class="sidebartext">
</div>
<div class="sidebartitle">
Coming Soon </div>
<div class="sidebartext">
</div>
<!-- InstanceEndEditable --> </p>

</div>

</div>
<div class="clear"></div>
<div class="copyright">
<div align="center" class="style1">&copy;Copyright 2010 Bradley Stoke Judo Club || Site Designed by Gem Gale || Site Hosted by <a href="http://www.wotwebsystems.com" class="link">WOT Web Systems</a></div>
</div>

</body>
<!-- InstanceEnd --></html>

Posted on 12th May, 2017
Donnataf
Absolutely NEW update of SEO/SMM software "XRumer 16.0 + XEvil 3.0":
captchas solving of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex,
and more than 8400 another size-types of captchas,
with highest precision (80..100%) and highest speed (100 img per second).
You can connect XEvil 3.0 to all most popular SEO/SMM programms: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other software.

Interested? There are a lot of demo videos about XEvil in YouTube.
Good luck ;)
Posted on 18th May, 2017
SandraMub
Absolutely NEW update of SEO/SMM package "XRumer 16.0 + XEvil 3.0":
captcha solving of Google, Facebook, Bing, Hotmail, SolveMedia, Yandex,
and more than 8400 another categories of captchas,
with highest precision (80..100%) and highest speed (100 img per second).
You can connect XEvil 3.0 to all most popular SEO/SMM programms: XRumer, GSA SER, ZennoPoster, Srapebox, Senuke, and more than 100 of other software.

Interested? There are a lot of impessive videos about XEvil in YouTube.
See you later ;)
Posted on 05th Jun, 2017
SamuelDaura
CHEAP CIALIS HERE
http://imgur.com/a/V4WUj
genaric cialis|
amad tootla cancer specialist|
buy generic cialis|
cardiovascular specialist assistant|
original cialis|
Posted on 14th Jun, 2017
Robertblawl
http://www.gagprincess.com
Posted on 23rd Jun, 2017
Robertblawl
http://www.gagprincess.com
Posted on 25th Jun, 2017
Peterbrura
http://domakostroma.com/
Posted on 02nd Jul, 2017
WaynePal
http://bit.ly/2tw1PvE
Posted on 09th Jul, 2017
TimothyFub
Hi there! cheapest mexican pharmacy online good web page.
Posted on 19th Aug, 2017
alaliaapolycl
Visit our website Alaliaa to take more information.
Posted on 03rd Sep, 2017
TimothyJet
http://haushaltshop.eu/ RekunsegeHeils
Posted on 14th Sep, 2017
masha2
Привет.
Posted on 25th Sep, 2017
AuigosTatty
Tramadols pills is employed to italian autostrada done with representing Buy Tramadol 150mg morose to regimen painstaking pain.
Tramadol, commonly known as Tramatas, Tranzex, buy generic ultram master Aurotrama and Tramol-SR is hand-me-down to lift normal to within via respectability of inexorable pain. It also may be euphemistic pre-owned to seat itch caused buy Ultram visa tramadols searching to surgery and long-lived conditions such as cancer or combined pain. ultram buy tramadol pills 100mg works sooner than decreasing the discernment's position and rejoin to pain. It also reduces the walk or immensity of the smarting order tramadol mastercard signal passed from inseparable obduracy to another. This medication is again prescribed as a substitute for of other uses; importune your doctor or posologist championing the allowances of more information.

Tramadol Ultram 50-200mg Order Online
Posted on 11th Oct, 2017
NIJesse
twvj.com
Posted on 03rd Nov, 2017
Corpoi87
osteoren recensioni


Nicely put. Regards!
Posted on 04th Dec, 2017
Steklobanki-bug
Крышки для консервирования оптом в Твери
- Стеклобанки оптом


































































Promo Code: ABYRVALG251295



Posted on 11th Dec, 2017
KevinhaB
АлкоБарьер – эффективное средство борьбы с алкоголизмом

Устраняет тягу к алкоголю
Восстанавливает поврежденные клетки печени
Выводит токсины из организма
Успокаивает нервную систему
Не имеет вкуса и запаха

АЛКОБАРЬЕР – СКАЖИ «НЕТ» АЛКОЗАВИСИМОСТИ!

==>> ow.ly/Od8Z30g0Mg3
==>> is.gd/ORMsK8
Posted on 20th Dec, 2017
ClaudePt
Tranquilite, equilibre et robustesse sont les mots principaux qui definissent notre sélection de jouets pour enfants. Spécialistes de l’univers velo enfant et des jouets d'exterieur, avec jouetjeu.com, nous plebiscitons des jouets stables et tous manufactures en Europe, garantis au meilleur prix chaque mois.
Posted on 31st Dec, 2017
XRumerTest
Hello. And Bye.
Posted on 20th Jul, 2018
soymn
Здравствуйте!
Предлагаю ТОПОВЫЙ курс:

как заработать на youtube с нуля
Posted on 22nd Jul, 2018
almazburTam
http://xrumer.su/ - Регистрация сайта в каталогах http://xrumer.su/ - xrumer.su
Posted on 17th Jan, 2019
Miltonloush
????? ?????? [url=https://clck.ru/F3Cqh]????? ?? ??????? ??????? ?????? ??????.[/url]
Posted on 17th Feb, 2019
Richardnom
??????? ?????????

??????? ?????????
Posted on 03rd Apr, 2019
JamesSet
???????? ???????? ???

???????? ???????? ???
Posted on 18th Apr, 2019
mat
Hello. And Bye.
Posted on 19th Apr, 2019
BruceruS
?????? ?????? ??????

????????? ?????
Posted on 22nd Apr, 2019
StevenFaf
?????? ??????????

????????? ??? ????????
Posted on 29th Apr, 2019
LauraEmbaw
????????? Samsung ???????????? ?? ????? ??????? ????????????? ? ?????? ??????? ?????????. ??????? ?????? ????????? ????????? ??????? ????? ???????? ??????????? ?? ??????????? ????, ????????? ?? http://no-lamer.ru
Posted on 09th May, 2019
Joshuascouh
??? ???????????

drester 3600 ?????
Posted on 05th Jul, 2019
JamesFeese
??????? ? ?????????

[url=http://advocat-dnepr.com.ua/]???????? ??????? ?????[/url]
Posted on 16th Jul, 2019
Jamesshabs
?????-??????

https://free.tw-sportslottery.com/
Posted on 16th Jul, 2019
Darylsop
???-??????????????????JM-180B?????????????????????????????????????

https://mic-shop.com/
Posted on 16th Jul, 2019
BrianBub
???-??????????????????JM-180B?????????????????????????????????????

https://mic-shop.com/
Posted on 17th Jul, 2019
RbaseoGisk
* ???????? ?????? ????? ?????
· ?? ??? ????? ?????????? ???????? ?? ??? ????
- ??? ???????? ??????? ?? 223 ???????????? ??????, 44 ??
· ?????, ???, ? ?????? ????? ? ????????????
- ??????, ?????? ?????? ????????????
- ?????? ?????
* ?????? ?????????????

https://baseo.ru
Posted on 17th Jul, 2019
RafaelLoomb
??? ?? ??????

http://interior-plan.com/
Posted on 17th Jul, 2019
Enriquesep
unethost???????? http://blog.unethost.com/
Posted on 18th Jul, 2019
Enriquesep
unethost???????? http://blog.unethost.com/
Posted on 19th Jul, 2019
Jamesshabs
?????-??????

https://free.tw-sportslottery.com/
Posted on 19th Jul, 2019
BrianBub
???-??????????????????JM-180B?????????????????????????????????????

https://mic-shop.com/
Posted on 19th Jul, 2019
Justinfus
???-??????????????????JM-180B????????????????????????????????????? https://mic-shop.com/
Posted on 22nd Jul, 2019
Jamesshabs
?????-??????

https://free.tw-sportslottery.com/
Posted on 22nd Jul, 2019
Tyronecrync
????????? - ???? ???? ????

http://50-video.com/
Posted on 22nd Jul, 2019
Sammyprere
???????????????A????????????DVD http://www.av-50.com/
Posted on 22nd Jul, 2019
RafaelLoomb
??? ?? ??????

http://interior-plan.com/
Posted on 22nd Jul, 2019
Darylsop
???-??????????????????JM-180B?????????????????????????????????????

https://mic-shop.com/
Posted on 22nd Jul, 2019
BrianBub
???-??????????????????JM-180B?????????????????????????????????????

https://mic-shop.com/
Posted on 22nd Jul, 2019
Justinfus
???-??????????????????JM-180B????????????????????????????????????? https://mic-shop.com/
Posted on 22nd Jul, 2019
Enriquesep
unethost???????? http://blog.unethost.com/
Posted on 23rd Jul, 2019
Jamesshabs
?????-??????

https://free.tw-sportslottery.com/
Posted on 23rd Jul, 2019
Justinfus
???-??????????????????JM-180B????????????????????????????????????? https://mic-shop.com/
Posted on 24th Jul, 2019
Enriquesep
unethost???????? http://blog.unethost.com/
Posted on 21st Aug, 2019
WilliamNer
trust pharmacy canadian generic viagra in us pharmacies canada pharmacy no prescription antibiotics/#trust pharmacy canadian
Posted on 30th Aug, 2019
Sovialen
?????????? ?????????? ????????? ?????????? ??????? ?????? ????? ?????.
Posted on 04th Sep, 2019
XRumerTest
Hello. And Bye.
Posted on 20th Sep, 2019
RaymondBeaps
????????????????

https://168cash.com.tw/
Posted on 29th Sep, 2019
CaseyNox
XYZ|????|??|??????|????|????|?????1000?200

http://xyz.net.tw/
Posted on 06th Oct, 2019
CaseyNox
XYZ|????|??|??????|????|????|?????1000?200

http://xyz.net.tw/
Posted on 06th Oct, 2019
EmmittMic
???????? ????? ??AV????? ???????? – AV????.????(??18???)

http://avgood-store.com/
Posted on 15th Oct, 2019
DonaldCruts
unethost???????? ???????

http://blog.unethost.com/
Posted on 25th Oct, 2019
ThomasCoige
????????????!
????? ??? ????? ????.

??? ??????? ????????...
?? ?????? ????? ?? ?????? ????? ????? ??????? ? ?????????
?????? ?????????? ?? ????:
[b]
https://werecommend.ru/review

[/b]
Posted on 27th Oct, 2019
stydayGah
essay for scholarships http://write-papers.essayhave.dasma-triskelion.site dialogue in an essay example
Posted on 28th Oct, 2019
DonaldCruts
unethost???????? ???????

http://blog.unethost.com/
Posted on 29th Oct, 2019
Michaelpayom
?????? ???

?????? ???
Posted on 05th Nov, 2019
Donaldchaws
XYZ|????|??|??????|????|????|?????1000?200

http://xyz.net.tw/
Posted on 05th Nov, 2019
ThomasItank
?????? ? ???????????? ??????? ?????

?????? ? ????????? ?????????
Posted on 07th Nov, 2019
RaymondBeaps
????????????????

https://168cash.com.tw/
Posted on 08th Nov, 2019
MichaelCooke
?????? ??????

https://gambling777.pro/malina-casino/
Posted on 12th Nov, 2019
SamuelEmula
??? ??????

????? ?????? ????
Posted on 12th Nov, 2019
AndrewVok
???????? ????? ?????? ???????????

[url=https://moneyconsulting.ru/blog/exclusive-vip-coaching-ot-andreya-chernyih-proektyi-passivnyiy-dohod-ot-200-000-dollarov-v-god-i-1-000-000-dollarov-na-partnerskoy-programme-andreya-chernyih/]???????? ????? [/url]
Posted on 14th Nov, 2019
Martyced
????????? https://fmb.tw/
Posted on 15th Nov, 2019
JasonKam
?????? ??????, ???????? ??????? ? ???? ?????? ????????? ? ??????? ????????

[url=http://55kino.ru/35274-chernaja-pautina-4-serija.html]http://55kino.ru/35274-chernaja-pautina-4-serija.html[/url]
Posted on 15th Nov, 2019
EmmittMic
???????? ????? ??AV????? ???????? – AV????.????(??18???)

http://avgood-store.com/
Posted on 19th Nov, 2019
Hollyseeva
Only for you....
Cheap personal essay writers website usa
professional assignment editing site for phd
Cheap annotated bibliography writer website online
how to submit resume online
https://essaywriting.vip/a-bad-experience-at-school-essay/business-school-research-proposal-outline.php
Posted on 20th Nov, 2019
ScottClida
??????????? ?????

????????? ?????
Posted on 20th Nov, 2019
Larrydiots
??????? ????? ????????? ??????? «??????» ?????! ???????? ? ?????? ??????? ?????? ?????????? ????? ??? ?.?. ??????? «??????» ????? ????????? ????????? ?????????????.
???????? ???? ??????? ???????? ????????? ????????????? ????? ???? ????????, ?.?. ????????? ??? ?????????? ??????????? ???????? - ???????? ????????? ???????????
Posted on 21st Nov, 2019
Bertramcek
??????????? ?????

????????? ?????
Posted on 21st Nov, 2019
CaseyNox
XYZ|????|??|??????|????|????|?????1000?200

http://xyz.net.tw/
Posted on 21st Nov, 2019
Martyced
????????? https://fmb.tw/
Posted on 21st Nov, 2019
RalphOxype
???????? ?????

????????? ?????
Posted on 23rd Nov, 2019
DonaldCruts
unethost???????? ???????

http://blog.unethost.com/
Posted on 25th Nov, 2019
Larrydiots
??? ?????? ? ????????? ????????? ??????? «??????» ?????! ?????? ? ???????? ??????? ?????? ?????????? ????? ??? ?.?. ??????? «??????» ????? ????????? ????????? ?????????????.
???????? ????????? ????????????? ????? ???? ????????, ?????? ??? ?????????? ????????????? ??????????? ???????? - ???????? ?.?.
Posted on 27th Nov, 2019
Kennethrof
????????????? ???? ?? ?????????????

?????? ?????? ?? 3 ???
Posted on 27th Nov, 2019
Jordanreips
????? ??????????? ??????????

??? ? ?????? ?? ????????????? ?? ????????
Posted on 28th Nov, 2019
Leoneltuh
?????


https://forum.tw-sportslottery.com/thread-119-1-1.html
Posted on 29th Nov, 2019
Eliasunsot
?????????? ????? ??????? ????? ?? ?????

?????????? ????? ??????? ?????
Posted on 30th Nov, 2019
FrankTab
?????? ??? ? ?????????? ?????? ?????????????

???????? ??? ?????????? ????? ????????????? ???????
Posted on 01st Dec, 2019
XRumerTest
Hello. And Bye.
Posted on 04th Dec, 2019
Jamesdearf
??????? ??????

??????? ??????
Posted on 04th Dec, 2019
DonaldCruts
unethost???????? ???????

http://blog.unethost.com/
Posted on 05th Dec, 2019
Leoneltuh
?????


https://forum.tw-sportslottery.com/thread-119-1-1.html
Posted on 07th Dec, 2019
EmmittMic
???????? ????? ??AV????? ???????? – AV????.????(??18???)

http://avgood-store.com/
Posted on 13th Dec, 2019
RaymondBeaps
????????????????

https://168cash.com.tw/

Your Answer:

Login to answer
139 Like 16 Dislike
Previous forums Next forums
Other forums

frame help
on the bottom frame is menu.html

Code: <body><form action='link.php' met

PHP Display Telephone Number On Referrer
I have used the php below to show a different telephone number in the header of the site depending u

Autentiske Montblanc Boheme kuglepen Montblanc Boheme kuglepen Enestående
[b][url=http://da.relomontreal.org/]Montblanc penne[/url][/b] [b]Montblanc penne[/b] Mont BlancMontb

Top kvalitet schweiziske replika BREITLING replika ure online .
schweiziske replika ure AAA +
schweiziske replika ure
[b][url=http://www.watchreplicaonline.

HTML Viewer HIDE scrollbar
How can I disable scrollbars in a HTML Viewer control? I can't hide them. Even i have enough space b

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Google+ Indyaspeak @ Pinterest RSS