Current location: Hot Scripts Forums » Programming Languages » PHP » Print Page, Page Breaks - Help


Print Page, Page Breaks - Help

Reply
  #1 (permalink)  
Old 11-20-04, 10:12 AM
spanky1968 spanky1968 is offline
New Member
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Print Page, Page Breaks - Help

I have a small problem. The attached code I have should print a page of sata and insert a page break so the output does not run on from one sheet to another. IE - If I have account information on the page and each account is seperated by a horizontal line the data from the last account should note start on one page and finsh on another. The problem is when the page breaks I loose the account info from the page directly after the break. Can someone please let me know what I'm doing wrong?

My Code as of now...
<?php
ob_start();
session_start();
?>
<html>
<head>
<title>Printer Friendly</title>
<?php
//this will include the meta.php file. It has the meta tags
include ('meta.php');
//this will check if the user has logged in. if not it will send them to the login.php page
if ($_SESSION['login'] == "") {
header('location: login.php');
}
?>
</head>
<body onLoad="history.go(+1)">

<form name="print" action="print.php" method="POST">

<p align="left">

<input type="submit" name="back" value="Go to the accounts in progress page">
&nbsp;
<input type="submit" name="cancel" value="Cancel This Request">
</p>
</form>


<p align="center">


<input type="button" value="Print This List" name="PrintBtn" onClick="window.print()" style="float: left">

</p>

<p align="center">&nbsp;</p>

<hr>
<blockquote>
<blockquote>
<blockquote>
<p align="center"><font color="#FFFFFF" size="4">
<span style="background-color: #FF0000; font-weight:700; font-style:italic">PLEASE NOTE - IF YOU WOULD LIKE TO PRINT
THIS PAGE PLEASE PRINT IT FIRST BEFORE MOVING TO THE &quot;IN PROGRESS&quot; QUEUE</span></font></p>
</blockquote>
</blockquote>
</blockquote>
<h3 align="center"><i><font color="#FF0000">
<span style="background-color: #FFFFFF"><font size="3">These account have now been flagged as "in progress"</font></span><b><span style="background-color: #FFFFFF"><font size="3"> Pressing "back" on your browser will not cancel this request. Please use the Cancel button
above. If you press "back" you can still cancel this request by moving all accounts back to the queue from the "accounts in progress" page.</font></span></b></font></i></h3>
<hr>
<?php
//this is setting the session created when the user logged in to a variable name called session. this will hold their name, to number etc etc
$session = ($_SESSION['login']);



include('mysqlconnect.php');
Include('mysqltable_data.php');
$sql_query = "select * from cmu_data where printing = '" . $session['tonumber'] . "' and queue = 'printing'";
$query_run = mysql_query($sql_query);
$break = 0;
$second_break = 13;
while ($query_res = mysql_fetch_array($query_run)) {
if ($break == 5) {
print "<br><br><br>";
$break++;
} elseif ($break == $second_break) {
print "<br><br><br><br><br>";
$second_break = ($second_break + 7);
} else {
print "<b>Account Number: " . $query_res['Account_Number'] . "</b><br>";
print "Bank Account Number: " . $query_res['Cust_Bank_Account'] . "<br>";
print "Debit Amount: $" . $query_res['Debit_Amount'] . "<br>";
print "PAP Change: " . $query_res['Change_PAP'] . "<br>";
print "Extension Payment: " . $query_res['Extension_Payment'] . "<br>";
print "<b>Special Instructions: " . $query_res['Special_Instructions'] . "</b><br>";
print "<hr>";
$break++;
}
}
mysql_close();
//if the user presses the back butten then go back to the cmureport.php page
if (isset($_POST['back'])) {
header("location: inprogress.php");
}

if (isset($_POST['cancel'])) {
include('mysqlconnect.php');
mysql_select_db('cmutest1');
$sql_query = "update cmu_data set printing = '', queue = '' where printing = '" . $session['tonumber'] . "' and queue = 'printing'";
$query_run = mysql_query($sql_query);
mysql_close();
header("location: cmureport_cmu.php");
}
?>
</body>
</html>
Reply With Quote
  #2 (permalink)  
Old 11-21-04, 08:33 AM
bizzar528's Avatar
bizzar528 bizzar528 is offline
Community Liaison
 
Join Date: Sep 2004
Location: Pennsylvania, US
Posts: 1,550
Thanks: 2
Thanked 16 Times in 15 Posts
I think you need to increment $break during your elseif statement. When it's looping through, $break doesn't change because of how you have your code.

Change:
PHP Code:

elseif ($break == $second_break) {

print 
"<br><br><br><br><br>";
$second_break = ($second_break 7);

To:
PHP Code:

elseif ($break == $second_break) {

print 
"<br><br><br><br><br>";
$second_break = ($second_break 7);
$break++;

__________________
Yep, it's a signature...
Reply With Quote
  #3 (permalink)  
Old 11-22-04, 07:03 PM
spanky1968 spanky1968 is offline
New Member
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks, I'll give it a try and let you know.
Reply With Quote
  #4 (permalink)  
Old 11-23-04, 04:00 AM
James Talbot James Talbot is offline
Newbie Coder
 
Join Date: Jul 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Also, when writing SQL Statements try to present it like this :

Your Code
PHP Code:



$sql_query 
"select * from cmu_data where printing = '" $session['tonumber'] . "' and queue = 'printing'";

$sql_query "update cmu_data set printing = '', queue = '' where printing = '" $session['tonumber'] . "' and queue = 'printing'"
Recommend way of writing that

PHP Code:



$sql_query 
"SELECT * FROM cmu_data WHERE printing = '" $session['tonumber'] . "' AND queue = 'printing'";

$sql_query "UPDATE cmu_data SET printing = '', queue = '' WHERE printing = '" $session['tonumber'] . "' AND queue = 'printing'"
Its juts easier to read and helps to debug.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Classified Ads skipper23 Perl 3 11-22-05 02:22 AM
formmail problem gscraper Perl 12 08-27-04 03:06 AM
Upload Script Problem!!! seanknighton Perl 0 03-21-04 09:54 PM
Classified Ads skipper23 Perl 2 12-30-03 03:43 AM
New to perl, could use some help Arowana Perl 4 10-24-03 10:49 AM


All times are GMT -5. The time now is 05:15 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.