Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Paging - I get pages multiplied by 10!
Old 03-11-2008, 10:34 PM Paging - I get pages multiplied by 10!
Novice Talker

Posts: 9
Name: Bob
Trades: 0
Hi everybody,

Exactly what the title says! And the funny thing is that if I click on page no.1 I get 10 results, if I click page no.2 I get 20 results, page no.3 30 results and so on... What am I doing wrong?

Here's my code:

PHP Code:
<?
if (!(isset($start))) { $start=0; }
$maxperpage=10;
$tend $start+$maxperpage

SOME SQL QUERY = (" ... LIMIT $start,$tend")
?>
****HERE I GET THE SQL RESULTS-OUTCOME****

and then towards the end of the page, I have the following code:

<a href=URL&start=0\">1</a>");

PHP Code:
<?
$more
mysql_query("SELECT * FROM * WHERE *** ") or die(mysql_error());
$more2mysql_num_rows($more);
$maxpage ceil($divide/$maxperpage); 
if ((
$more2/$maxperpage)>$maxpage) { $maxpage=$maxpage+1; } 
for (
$j=1;$j<$maxpage;$j++){
$cs = ($j*$maxperpage); $cp $j+1;
print(
" | <a href=URL&start=$cs>$cp</a>");  
}
?>
The outcome of the code above is like this:

Pages: 1, 2, 3, 4, 5 etc.

and every time I click on any number I get the SQL results-records multiplied by 10 (e.g. if I click on 3 I get 30 results per page, on 5 I get 50! etc).

Any help would be GREATLY appreciated!

Last edited by bob25; 03-12-2008 at 10:58 AM.. Reason: php tags - newbie!
bob25 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-12-2008, 12:58 AM Re: Paging - I get pages multiplied by 10!
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
If only code tags had been used... Such a shame when one wants to help.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 03-12-2008, 01:41 AM Re: Paging - I get pages multiplied by 10!
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Code:
$tend = $start+$maxperpage;

$ SOME SQL QUERY = (" ... LIMIT $start,$tend")
$tend is the number of records to select, not the position of the last item being selected. You should say "... limit $start, $maxperpage" instead of your query.

And don't forget to give me talkupation.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 03-12-2008, 11:23 AM Re: Paging - I get pages multiplied by 10!
Novice Talker

Posts: 9
Name: Bob
Trades: 0
Quote:
Originally Posted by JeremyMiller View Post
If only code tags had been used... Such a shame when one wants to help.
OK Post edited.
To be honest, I don't see any difference to the code I posted though - it's still the same with or without the php tags.


Quote:
Originally Posted by mtishetsky View Post
Code:
$tend = $start+$maxperpage;

$ SOME SQL QUERY = (" ... LIMIT $start,$tend")
$tend is the number of records to select, not the position of the last item being selected. You should say "... limit $start, $maxperpage" instead of your query.

And don't forget to give me talkupation.
Mtishetsky, you're the man - thanks a ton! It works like charm! (talkupation left)
Do I have to edit anything else in the code? Or leave it as it is?
bob25 is offline
Reply With Quote
View Public Profile
 
Old 03-12-2008, 11:39 AM Re: Paging - I get pages multiplied by 10!
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Quote:
Originally Posted by bob25 View Post
OK Post edited.
To be honest, I don't see any difference to the code I posted though - it's still the same with or without the php tags.
Nope, it's highlighted and had you used any indentation, it would be indented. In short, it would be more readable.

Quote:
Originally Posted by bob25 View Post
Do I have to edit anything else in the code? Or leave it as it is?
That should be all you need to change. If you're not using $tend anywhere else, however, you could remove it too.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Reply     « Reply to Paging - I get pages multiplied by 10!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15714 seconds with 12 queries