Free Webmasters Resources, Webmaster Tools, CGI Scripts, Web Tutorials, Web Articles  

Dating Services Software
Navigation
Home
Advertise
Webmaster Forums
Webmaster Resources
Webmaster Tools
Web Articles
Tutorials
Free Newsletter

Link To Us
Site Map
About Us
Search
Contact

Webmaster Resources
Resource Home
Submit Resource

Commerce
Free Services
Learning
Online Tools
Our Webmaster Tools
Promotion
Scripts
Software
Web Hosting
Website Design


Webmaster Tools
SEO Tools

- Meta Tag Generator
- Google Position Checker
- Keyword Density Analyzer
- Keyword Generator
- Link Popularity Checker
- Meta Tag Analyzer
- Search Index Report
- Search Engine Simulator
- Web Page Analyzer
- Yahoo Position Checker

HTML Tools

- Color Chart
- Color Converter
- Dreamweaver Code Cleaner
- Frontpage Code Cleaner
- HTML Entities List
- Web Page Size Checker

Domain Tools

- Domain Typo Generator
- Whois Lookup

Other Tools

- HTTP Headers Viewer
- IP Address


Free Newsletter
This is a private mailing list and will never be sold or given away for any reason. Newsletter sent out in HTML format.


First Name:


Email Address:




More Information
Archives


Poll
Where do you live?
Africa
North America
South America
Asia
Australia/Pacific
Europe
 

Results
Past Results


Site Search
Search this entire Website for articles, tutorials, reviews and other resources.


Adv. Search

Scripts & Programs
Submit Script

ASP Scripts
C and C++ Scripts
JavaScripts
Perl and CGI Scripts
PHP Scripts
Remotely Hosted


Web Articles
Submit Article

Coding
eZine Production
Marketing Tips
Online Business
Other Internet Articles
Search Engines
Web Design
Web Hosting


Tutorials
Submit Tutorial

ASP Tutorials
C and C++ Tutorials
ColdFusion Tutorials
DHTML Tutorials
Flash Tutorials
Graphic Tutorials
HTML Tutorials
JavaScript Tutorials
Perl Tutorials
PHP Tutorials
Web Design Tutorials
XML Tutorials


How To Put Your Articles Into Seperate Pages

Home Page :: Authors Login :: Author Signup :: Search :: More Articles

Home :: PHP/MySQL


About This Author :: Request Reprint :: Print Article :: Tell A Friend


How To Put Your Articles Into Seperate Pages
By Ben Sinclair
Contact Ben Sinclair


This is a cool little way to put articles from a page or database into seperate pages. This can be done quite a few ways but here's one of them. So lets get into it!

The Article Part

Lets say this is your (extremely short) article:

Hello,

This article is about nothing much... This is just here for a page example.

I could go on forever... bla bla bla bla bla bla bla bla bla bla

And again... bla bla bla bla bla bla bla bla bla bla bla.


OK, you want to "cut up" the article into 3 seperate pages so that it is displayed better and is easier to read. This is what you would add to your article. You'll need to add a little bit of PHP:


<?php
$pages
= "3"; // How many pages you want on the page
$article = <<<EOF
Hello,

This article is about nothing much... This is just here for a page example.

{ENDPAGE1}
I could go on forever... bla bla bla bla bla bla bla bla bla bla

{ENDPAGE2}
And again... bla bla bla bla bla bla bla bla bla bla bla.

{ENDPAGE3}
EOF;?>



The Code

Now that your article has been "cut up", you'll need this code belwo the above code:


<?php
// Remove this code below if you don't
// what it to add breaks (<BR>) automatically.
$article = nl2br($article);

// Make sure there are no stuff ups.
if ($pages > 1) {
if (!
$page || $page <= "0") {
$page = "1";
}
$article = "{ENDPAGE0} ".$article;
$pagea = $page - 1;
$pageb = $page + 1;

// Check that the page exists
$match_count = preg_match_all("/{ENDPAGE"."$pagea"."}(.*?){ENDPAGE"."$page"."}/is", $article, $matches);
if (
$match_count == "" || $match_count == "0") {
$article = "This page does not exist!";
} else {
if(
preg_match( "/{ENDPAGE"."$pagea"."}(.*?){ENDPAGE"."$page"."}/is", $article, $match ) )
$article = $match[1];
}

// Generate Page Numbers
if ($page > "1") {
$prev = "<a href=\"$PHP_SELF?page=$pagea\"><< Prev</a> :";
} else {
$prev = "<< Prev :";
}
if (
$page < "$pages") {
$next = ": <a href=\"$PHP_SELF?page=$pageb\">Next >></a>";
} else {
$next = ": Next >>";
}
for (
$p=1 ;$p <=$pages&nbsp; ; $p++ )
{
if (
$page == $p) {
$direct_bar .= "<b>$p</b>�";
} else {
$direct_bar .= "<a href=\"$PHP_SELF?page=$p\">$p</a>�";
}
}
}

// Finish off the page
print <<<EOF
<p>$prev $direct_bar $next</p>
EOF;
print
$article; // Put article onto page

print <<<EOF
<p>$prev $direct_bar $next</p>
EOF;?>



And that's it! You should now have three pages instead of one. This really helps to make it all look neat. This same thing can be done with MySQL or any other database just by selecting the article out of the database.

Enjoy!

Discuss this in our Webmaster Forums

About The Author:
Ben Sinclair

Ben Sinclair is the Webmaster of Webmaster Resources 101(/)

Go To Top

This article has been read 4 times.


About This Author :: Request Reprint :: Print Article :: Tell A Friend



Advertising
Advertise your website here. View Advertising Information.

Google Ranking Tool
Search Engine OptimizationGet This Tool Free!

Home   Search   Contact   About Us  

Hot Resources
We have found some of the Hottest Resources around just for you! Check these out:
Search Engine Promotion
- Search engine specialist
- Over 200 clients worldwide
- SEO as low as $499
- Link Building for $150

More info...

Online Dating Script

aeDating 3.0 new version of famous dating software with free installation, lifetime upgrades and technical support. New templates, private photos, credits payment system, integrated with phpBB, banner system, new IM.

Visit resource

Search Engine Placement
Since 1997 StepForth has been a result and client oriented search engine optimization and placement company. Our SEO services are guaranteed and proven. Questions? Contact us: 1-877-385-5526

More info...

Best Web Hosting!
- LunarPages ($7.95)
- iPowerWeb ($7.95)
- Globat ($7.50)
- PowWeb ($7.77)

WebHosting $7.50/mo
$7.50/mo - 1000 MB Space, 40 GB Transfer, 24/7 Support, 99.9% Uptime, FREE Domain and FREE Setup.

More info...


Sponsors
Web Hosting
Web Hosting India
StartLogic
Web Hosting
Cheap Web Hosting

Search Engines
Search Engine Optimization SEO
NetVisits Web Directory
Search Engine Optimization

Webmaster Tools
Webmaster Resources

Software
MAS 90

Domain Names
Resell Domain Names and More!

Link Popularity
Reciprocal Link Exchange Directory
Link Building Campaigns

Great Deals
Cheap Flights
Cheap Car Rental
Cheap Mobile Phones
Plasma Televisions



Partners
Dreamweaver Web Templates
Motivational Memo
Website Advertising
Php Scripts
Cheap Web Hosting
Cheap Web Host
Free Webmaster Resources
Need CGI
Desro Webmaster Resources
Web-Mastery Web-Resources
Top 10 Hosts - PHP MySQL

Books
JavaScript: A Beginners Guide

JavaScript: A Beginners Guide


The Hottest Reseller Program Going!

Contact Information

Powered by Outasight Enterprises Pty Ltd
PO Box 1218 Mudgeeraba QLD 4213 AUS
All content � Webmaster Resources 101, 2002-2004 unless otherwise stated.
Design by OE Design Hosted by Surf Speedy View our Privacy Policy
Page loaded in 2.408 secs.
6 users online.

The Hottest Reseller Program Going!