[advanced search]
Results from the most recent live auction are here.
12 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 06-07-2008, 02:19 PM   · #1
-LB-
SOADtalk
 
-LB-'s Avatar
 
Name: Lewis Beechey
Location: Leics, England
Trader Rating: (21)
Join Date: Dec 2005
Posts: 889
NP$: 25.00 (Donate)
-LB- is just really nice-LB- is just really nice-LB- is just really nice-LB- is just really nice
Alzheimer's
Help with Pagination

Well, I need some help on getting page numbering on my website, http://soadtalk.com without using a database.

A you can see the site has a lot of content on the main page and I want to have page numbering at the bottom so it's like:

Quote:
« 1 2 3 4 5...25 »



If you could post some sort of code or direct me into a website which can tell me how to do this in easy steps (i'm seriously no PHP expert) then that would be awesome.

Thanks,
Lewis

Edit:// I'm manually adding news articles to main.php which index.php is including but the content just builds and builds and builds and i wanna neaten it up nicely. any help is appreciated.


Please register or log-in into NamePros to hide ads
__________________
"Pretending that we live doesn't make us alive" - Serj Tankian & Iommi
-LB- is offline  
  Reply With Quote
Old 06-07-2008, 03:04 PM   · #2
mholt
DNOA Member
 
mholt's Avatar
 
Name: Matthew Holt
Location: 127.0.0.1
Trader Rating: (75)
Join Date: May 2004
Posts: 4,869
NP$: 17.21 (Donate)
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
Hm, it depends how easily you want to be able to maintain the "pages" of content.

Write a page of content, surround it with a PHP statement that says something like "if p=1, then show this, else if p=2, show this, else ... etc." ...

So you could do it with IF statements, or you could get a little fancier and do a loop (store each HTML post in an array element)... then treat it like a database query.

If you want to get more detailed, just ask.
__________________
www.mwholt.com
mholt is offline   Reply With Quote
Old 06-07-2008, 03:04 PM   · #3
psalzmann
NamePros Regular
 
Trader Rating: (20)
Join Date: Feb 2006
Posts: 517
NP$: 360.80 (Donate)
psalzmann is just really nicepsalzmann is just really nicepsalzmann is just really nicepsalzmann is just really nice
One of the more challenging tasks you'll face as a PHP programmer. You'll find great pagination examples and then you'll find more complicated and challenging.

Usually the more challenging will give you much better looking pagnation results:

[Prev 1 20 30 50 100 250 Next]

vs

[1 2 3 4 5 6 7 8 9 10 11 12 13 14 ..... 250]

So I mean not only will you need to handle the SQL portion (to limit each result based on the current page (ie: if you allow 10 results per page, and your viewing page 3 that means you need to serve results 30 to 40)..

Then once you determine that you're going to need to group some results so your pagnation is not going 1 2 3 4 5 .. instead it's 1 5 20 50 100 250... depending on how many pages you'll be spanning the 10 results per page on.

I know this isn't much in terms of helping you with code, but you need to know that this is not as simple as it appears. There is much going on to get "great" looking pagniation results.. I would search the web for some examples.. but remember that the page grouping is a great feature just in case your db has more than 1,000 results.

But one thing I do know, once you figure out what works for you, you'll begin refining it to your exact look and feel. What is more, you'll be able to reuse this code for other projects you may have.

Good luck!

I'm very sorry about my response. I just realized that you mentioned you are not using a db.
psalzmann is offline   Reply With Quote
Old 06-07-2008, 03:39 PM   · #4
mholt
DNOA Member
 
mholt's Avatar
 
Name: Matthew Holt
Location: 127.0.0.1
Trader Rating: (75)
Join Date: May 2004
Posts: 4,869
NP$: 17.21 (Donate)
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
Yeah, it's not too bad if you store your HTML content as array elements. You know an array is a container: much like a big shipping box with a bunch of little boxes inside it, each one numbered, the numbering starting at 0.

PHP Code:
$myarray[0] = "woohoo";
$myarray[1] = "something else";
$myarray[2] = "this would be another individual post, see?";


If you don't mind having one file for each post you make then do this:

- Create a subdirectory, call it "/posts" (or whatever you want).

- Use PHP to read all files in that directory. You can do this by date or by file name, if you named your files things like 1.html, 2.html... if you want the most recent on top, you'll need to sort descending - easy to do. Either way, there are options here.

- Read the contents of each file and put the contents into an array.


See, as you read from a database, all the results are stored in an array anyway (generally speaking). So this now can work just like a database query:

- Run a loop on the array (a for loop might be best), depending on what page you're currently on, how many per page, etc.

That should be pretty flexible.

Once your code is done, all you have to do is make a .html file in the /posts directory and make its name (a number) 1 more than your post before. See?
__________________
www.mwholt.com
mholt is offline   Reply With Quote
Old 06-08-2008, 02:06 AM   · #5
-LB-
SOADtalk
 
-LB-'s Avatar
 
Name: Lewis Beechey
Location: Leics, England
Trader Rating: (21)
Join Date: Dec 2005
Posts: 889
NP$: 25.00 (Donate)
-LB- is just really nice-LB- is just really nice-LB- is just really nice-LB- is just really nice
Alzheimer's
Hey,

I'm now using a CMS news system (Fusion News) and have tweaked it to my liking but I shall be taking all of the comments you have have given in so I can apply them to my other sites.

Thanks a lot!
__________________
"Pretending that we live doesn't make us alive" - Serj Tankian & Iommi
-LB- is offline  
  Reply With Quote
Reply

NamePros is a revenue sharing forum.

Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
Proof is in the Parking Exdon http://www.mobisitetrader.com/
Advertise your business at NamePros
All times are GMT -7. The time now is 09:42 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0