|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
PHP-General - Need help with the maths on this
Basically each page i have is split up into 7 sections 1 for each post.
Each post has an anchor link on it with "#1, #2" etc. So people can link right to that post. Which is fine until i get onto a second page. I am not sure how to work out which post to go to in the header redirect. For example if there are 8 posts there will be two pages right? Page two will only have one post. How will i go about working that out for each page based on how many posts? |
|
#2
|
|||
|
|||
|
PHP Code:
Do a search on pagination
__________________
9 out of 10 PHP problems can be resolved by setting PHP Code:
Remember, the command line is your friend Development Projects: PHPExcel PHPPowerPoint |
|
#3
|
||||
|
||||
|
I honestly don't get what you just posted at all it doesn't seem to be right?
I take it $pageNumber is 7 percent of $post or what? |
|
#4
|
|||
|
|||
|
Quote:
You obviously haven't actually tried to see what the code snippet does, or tried reading about it in the PHP manual, or tried googling or searching the forums for pagination. Try doing those things before telling me I'm not right; and then, if I really am not right, try explaining what you want in more detail. I did make one mistake, but the general principle is still correct PHP Code:
Last edited by Mark Baker : July 2nd, 2009 at 08:00 AM. |
|
#5
|
||||
|
||||
|
I tried the code and it simply doesn't work, $postNumber doesn't give me the right value.
Also i don't see how exactly i was supposed to know a percentage symbol didn't mean that, the whole point of me posting here is to get help. For this code does $post mean the actual post number, or the amount of posts? |
|
#6
|
|||
|
|||
|
$post = total number of posts.
$postPage = page number $postNumber = value that goes into the anchor tag #1, #2 etc.
__________________
Why do we always seek someone, something or some thought, are we afraid of ourselves? "The love of one's country is a splendid thing. But why should love stop at the border?" - Pablo Casals |
|
#7
|
||||
|
||||
|
Thought it might be that, altho the postNumber gives no value.
|
|
#8
|
|||
|
|||
|
PHP Code:
gives Code:
1 is posting number #1 on page 1 2 is posting number #2 on page 1 3 is posting number #3 on page 1 4 is posting number #4 on page 1 5 is posting number #5 on page 1 6 is posting number #6 on page 1 7 is posting number #7 on page 1 8 is posting number #1 on page 2 9 is posting number #2 on page 2 10 is posting number #3 on page 2 11 is posting number #4 on page 2 12 is posting number #5 on page 2 13 is posting number #6 on page 2 14 is posting number #7 on page 2 15 is posting number #1 on page 3 16 is posting number #2 on page 3 17 is posting number #3 on page 3 18 is posting number #4 on page 3 19 is posting number #5 on page 3 20 is posting number #6 on page 3 21 is posting number #7 on page 3 22 is posting number #1 on page 4 23 is posting number #2 on page 4 24 is posting number #3 on page 4 |
|
#9
|
||||
|
||||
|
That is strange i currently have this:
PHP Code:
Where $post_count is set via the replies field in the database table. It seems to go up until 9 then go to a second page, and then go to #3 this is strange. Last edited by liamdawe : July 2nd, 2009 at 08:13 AM. |
|
#10
|
|||
|
|||
|
|
|
#11
|
|||
|
|||
|
in just the pure number of hours you will be spending on little items like this over the next few months I highly suggest buying a book on php/mysql.
I personally think a great starter is the book by ullman and it handles things like pagination (which is what you are trying to do). It may seem rude, but meant in jest.....RTFM or buy a good starter book. It will save you hundreds of wasted hours. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > PHP-General - Need help with the maths on this |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|