WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Printer friendly pages from anywhere on a website.
Categories : PHP, Strings, Content Management Click here to Update Your Picture
lalith nayak
Date : Jan 28th 2006
Grade : 3 of 5 (graded 6 times)
Viewed : 12167
File : No file for this code example.
Images : No Images for this code example.
Search : More code by lalith nayak
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

Printer friendly pages from anywhere on a website. This dynamic "Print This Page" script works right out of the box - cut and paste. Has the option to leave images in the new print friendly page if required. Just link to this script, and it will give a printer friendly version of any page, whether it's a PHP, ASP, CGI, or HTML page. Comes with a Cascading StyleSheet for further control of your print-friendly pages.


Type: application
Version: 1
Requires: PHP 4, Any Platform
Author: the mighty Indian


<?php 

/*
PHPrint - Save this as file: phprint.php
Make any Page Printer Friendly!

After installation, you can remove text from here down to the next: 8< ---->
Back up/copy this file first.

1. Save this script in the root of the site for simplicity.
2. Place <!-- startprint --> somewhere in your HTML page where you consider 
it to be the start of printer friendly content, and <!-- stopprint --> goes at the end
of that same content.

3. You place a link to phprint.php anywhere on the HTML page (preferably outside the printed content,
like this: <a href="/phprint.php">Print this page</a>
- or however you like, just as long as you link to this script.

*/ 

//Do you want to strip images from the printable output?
// If no, change to "no". Otherwise, images are stripped by default.
$stripImages = "no";
// If you've already tested, you can remove the text from here up to the other: 8< ---->

// That's it! No need to go below here. Upload it and test.

$startingpoint = "<!-- startprint -->";
$endingpoint = "<!-- stopprint -->";

$read = fopen($HTTP_REFERER, "rb");
$value = "";
while(!
feof($read)){
   
$value .= fread($read, 4096); 
}
fclose($read);
$start= strpos($value, "$startingpoint"); 
$finish= strpos($value, "$endingpoint"); 
$length= $finish-$start;
$value=substr($value, $start, $length);

function
i_denude($variable){
    return(
eregi_replace("<img src=[^>]*>", "", $variable));
}

function
i_denudef($variable){
    return(
eregi_replace("<font[^>]*>", "", $variable));
}

$PHPrint = ("$value"); 

if (
$stripImages == "yes") {
   
$PHPrint = i_denude("$PHPrint");
}

$PHPrint = i_denudef("$PHPrint");
$PHPrint = str_replace( "</font>", "", $PHPrint );

echo
$PHPrint

flush(); //force 
?>



Simple Email address validation
Categories : Email, PHP, Strings
Look for the *position* of the first occurence of string2 in string1, beginning at position start.
Categories : Complete Programs, PHP, Strings
Filter - A simple class that lets you use multiple functions to create custom filters.
Categories : PHP, PHP Classes, Strings
Phorum, MySQL, Language, UK date format, MySQL UK Date format
Categories : PHP, Date Time, Strings, MySQL, Databases
function textwrap will wrap text to any desired width using <BR>\n as the default line break. Default wrap width is 80 columns.
Categories : Strings, HTML and PHP, PHP
String Replacement and speed consideration
Categories : PHP, Strings, Regexps
Massreplace
Categories : Filesystem, Regexps, Strings, PHP
how can I read the entire contents of a file into a string?
Categories : Filesystem, Strings, PHP
GroupIT Content Management and Community Engine
Categories : PHP, Complete Programs, Content Management
PHP5 URL Object
Categories : PHP, PHP Classes, URLs, Strings
SAPIPROCESSOR - is a compact XML-based CMS toolkit
Categories : PHP, Content Management, XML
RPE - Remote PHP Editor (v1.0)
Categories : PHP, Content Management, Code Editors
Rich Editor (RE) is a cross-browser WYSIWYG html editor
Categories : Content Management, Editors and IDEs, PHP, Complete Programs
The Porter Word Stemming Algorithm in PHP Reduces words to their base stem for search engines and indexing
Categories : Algorithms, PHP, Strings
WWW interface to Unix Manual(phpMan)
Categories : Program Execution, Strings, Arrays, PHP
 shahrul kassim wrote : 1676
i got this error
Warning: feof(): supplied argument is not a valid stream resource in C:\...\phprint.php on line 33

Warning: fread(): supplied argument is not a valid stream resource in C:\...\phprint.php on line 34

can anyone give some suggestion. im using php 5
 
 Kenneth Hamm wrote :1767
Great script.  Thank you.  Everything works as described 
except when used for my forms page.  If someone fills in 
the text windows on the form then clicks the printer 
friendly page link (before submitting the form), the text 
windows on the printer friendly page are all blank.  Is 
there any way to keep the info entered in the text boxes 
so it can be printed out with the rest of the form?

Many thanks.