Results 1 to 9 of 9

Thread: help w/agebreak

  1. #1
    Join Date
    Apr 2013
    gastonia NC

    help w/agebreak

    Hi, I'm trying to print this doc with heading at top of each printed page,
    page# at bottom of each page, thousands "," at "totdue" and without the
    filename on each page. any help? Thanks
    Following is my current code

        @page { size 8.5in 11in; margin: 2cm }
        div.page { page-break-after: always }
    <div class="page">
    mysql_select_db('homedb') or die("Unable to select database");
    $query=" SELECT * FROM oocust WHERE payrec = 'R' AND pd = 'N' ORDER BY datepaid ASC";
    echo date('m/d/y'); 
    echo "<font size=+1><b><center> Accounts Receivable Report</font></center></b></b><br />";
    <table cellspacing=0 cellpadding=2 border=1>
    <th colspan=4></th>
    <th bgcolor="#ccffff">date</th>
    <th bgcolor="#ccffff">days</th>
    <th bgcolor="#ccffff">amt</th>
    <th bgcolor="#ccffff">recur?</th>
    <th bgcolor="#ccffff">acct#</th>
    <th bgcolor="#ccffff">creditor</th>
    <th bgcolor="#ccffff">purpose</th>
    <th bgcolor="#ccffff">due</th>
    <th bgcolor="#ccffff">late</th>
    <th bgcolor="#ccffff">due</th>
    while($row = mysql_fetch_array($result))
    $totdue += $row['amtdue'];     
                echo '
                <td>', $row['status'], '</td>
                <td>', $row['acctno'], '</td>
                <td>', $row['bname'], '</td>
                <td>', $row['purpose'], '</td>
                <td>', $row['duedate'], '</td>                
           <td align=right class="currency">', ($late > 120 ? 'pastdue' : $row['dayslate']), '</td>
     <td align=right class="currency">$'.number_format($row['amtdue'],2).'</td> // ****perfect****
        echo '
           <th bgcolor="#ccffff" scope="row" colspan="6">Grand Total:</th>
           // <td bgcolor="#FFD4D4" class="currency">$', number_format($totdue, 2, '.', ''), '</td>
     <td align=right class="currency">$'. number_format('$totdue',2).'</td> // no thousands "," ***
        echo "Page 1";
        <div class="page">
        echo "Page 2";

  2. #2
    Is this homework or something? This is like the seventh time on three different forums in two weeks I've seen basically this same buggy, broken, garbage 1997 train wreck of code.

    Some tips:

    1) quotes aren't optional on attributes after 1997

    2) attributes like bgcolor and tags like CENTER and FONT have no business on websites written after 1997.

    3) this is 2014 not 2004, you shouldn't be using mysql_ functions either, hence the giant red warning boxes in the manual?

    4) You seem to know THEAD, have you ever heard of TFOOT? Guess what it does. You also aren't declaring a TBODY, so your THEAD isn't doing jack ****.

    5) pagination is handled client-side, the ONLY place you'd be able to set that is using CSS with generated content; even Javascript can't say what page is being printed.

    6) There are other tags and attributes you should be using like CAPTION and SCOPE.

    7) you want headings split, split them with breaks and not as separate elements, that's semantic gibberish.

    8) instead of targeting page for dimensions, you should just let the page do what it does -- why? because you don't know what size paper the user it printing to!

    9) turning off error reporting is BAD, no, REALLY BAD... As in "are you nuts?" BAD.

    Now, because TFOOT has to go before THEAD, we have to buffer the output of the rows as we add them up -- or we run a separate query for the total. Laughably, the second query might be faster.

    echo '
    	<table id="accountsReceivable">
    		<caption>Accounts Receivable Report - ', date('m/d/y'), '</caption>
    				<th scope="col">recur?</th>
    				<th scope="col">acct#</th>
    				<th scope="col">creditor</th>
    				<th scope="col">purpose</th>
    				<th scope="col">date<br />due</th>
    				<th scope="col">days<br />late</th>
    				<th scope="col">amt<br />due</th>
    				<td colspan="7">
    					<span class="pages"></span>
    $db = new PDO(
    	'root', // username
    	'xxxxx' // password
    $statement = $db->query('
    	SELECT * FROM oocust
    	WHERE payrec = 'R'
    	AND pd = 'N'
    	ORDER BY datepaid ASC
    while ($row = $statement->fetch()) {
    	echo '<tr>
    				<td>', $row['status'], '</td>
    				<td>', $row['acctno'], '</td>
    				<td>', $row['bname'], '</td>
    				<td>', $row['purpose'], '</td>
    				<td>', $row['duedate'], '</td>                
    				<td>', (
    					$row['dayslate'] > 120 ? 'Past Due' : $row['dayslate']
    				), '</td>
    				<td class="currency">
    					', number_format($row['amtdue'], 2), '
    	$totdue += $row['amtdue'];     
    echo '<tr class="grandTotal">
    				<th scope="row" colspan="6">Grand Total (USD):</th>
    				<td class="currency">
    					$', number_format($totdue, 2), '
    As to showing the page numbers, that takes a bit of CSS that... gimme a sec.

    body {
      counter-reset: page;
    #accountsReceivable .pages:before {
      counter-increment: page;
      content: counter(page);
    Last edited by deathshadow; 05-20-2014 at 03:53 PM.

  3. #3
    Join Date
    Apr 2013
    gastonia NC
    Hi Dead Shade, I must say here that I really stand in awe of your coding knowledge.
    I compare you (positively) , your demenour and expertise to "House", you know, the TV
    show. The reason being, I consider you among the best and if you were a doc
    I would look to you. Sticks and stones...
    Notice: Undefined variable: totdue in C:\xampp\htdocs\invoice\ap_report.php on line 49

    1) use the CODE tags on the forum, it might help us make sense of your code logic.

    I didn't intend to bypass the CODE tags - old age = little (no) memory.

    2) CSS exists for a reason, use it. This is 2014 not 1997, even in testing you shouldn't
    be trying to use BGCOLOR or ALIGN. Likewise targeting via CSS means you should have
    one markup for ALL your media targets, so that 'print' class and DIV for nothing around
    the table doesn't make much sense.

    If I were coding for public use I would definitely not be using the attributes that I
    enjoy but this is LOCAL and my pastime and I enjoy seeing what I can get away with.

    3) Semantics exist for a reason, that DIV at the top should be either a H1 or H2 before
    the table -- or even more semantically a CAPTION inside the table.

    yeah, as I encounter these issues I try for documentation - The PHP manual is difficult -
    like you already know so they're kinda reminding, otherwise, where's the need for forums?

    4) the lack of sensible formatting (which I was able to get from the forum's quote feature),
    string additions for no reason, and opening/closing of PHP for no good reason is most
    likely a hefty part of what's biting you on that code... Especially even using that garbage
    "endforeach" nonsense.

    That"endforeach" nonsense was suggested by a forum moderator. Looking at the PHP site,
    I read "endoreach does not exist"

    5) you can't add classes on the CLOSING tag of an element. </table class="print"> is
    gibberish. Classes go when you OPEN it, not when you close it.

    Again, if not for you (caustic remarks and all), I would not be aware of this

    6) You are opening THEAD more than once...
    My bad

    7) you aren't closing your TR

    Again, inattention on my part

    8) your THEAD content seems to have nothing to do with the values being displayed...

    9) You're declaring THEAD, where's your matching TBODY?

    10) Most of what you are trying to do is THEAD and TFOOT's job, with CSS 2.1's assistance.

    8,9 & 10 - I'm reading up on now

    11) Even in testing, get a PROPER head and doctype on it, as browsers (even so called compliant ones) can behave differently without them! It shouldn't be a headache to copy/paste a standard document start on there.

    I thank you

    12) Beware that even though we theoretically have print.css -- both Firefuxxors and Interdebt
    Exploder apply their own styling over it and seem to for some jacktarded reason think your
    screen.css should still be applied. You can optionally turn that behavior off as a user,
    but not as the developer.

    I'm not sure about your last line

  4. #4
    Quote Originally Posted by 12Strings View Post
    I didn't intend to bypass the CODE tags - old age = little (no) memory.
    No problem, with this parkinsonism I'm not too far behind you :P

    ... and yeah, you have to define $totdue first, add $totdue = 0; before the "while".

    Quote Originally Posted by 12Strings View Post
    If I were coding for public use I would definitely not be using the attributes that I
    enjoy but this is LOCAL and my pastime and I enjoy seeing what I can get away with.
    Strange as it sounds, it's actually easier not to declare them over and over like that. Since it's in your THEAD You can say it once in your CSS instead of many times in the markup -- one big tip; find a editor that lets you run multiple windows instead of tabs, so you can put your markup side-by-side with your stylesheet. Since on todays widescreens you have plenty of horizontal space, having the markup on one side and CSS on the other is a lot easier than scrolling up and down in the same file, or writing the same thing over and over again in the markup.

    It also helps establish the good practice of NEVER saying what things look like in the markup.

    Quote Originally Posted by 12Strings View Post
    That"endforeach" nonsense was suggested by a forum moderator. Looking at the PHP site, I read "endoreach does not exist"
    There's a lot of outdated/outmoded advice out there - it makes things hard for those starting out or just doing things casually when there are decade and a half out of date practices still being taught or promoted. More so in PHP as the latest versions are getting rid of a LOT of the outdated/broken methodologies. See PDO/mySQLi vs. the old mysql_ functions -- 90%+ of the code people are still writing uses mysql_connect and it's kin, when we've been told for eight years to stop doing so and for just over two years there's been giant red warning boxes that they're going away and WILL STOP WORKING soon; yet the majority of people writing tutorials, books and new sites are dragging their heels; sad when the old functions are ridiculously vulnerable not just from a sanitation of input standpoint, but also in terms of scope.

    As such, it's very easy to get bad advice as most people are still stuck in the past and not updating their skillsets.

    Quote Originally Posted by 12Strings View Post
    8,9 & 10 - I'm reading up on now
    If you want a decent 'plain english' explanation of HTML tags, I suggest this older reference -- it's spot on:

    But to break it down quick:

    THEAD wraps sets of TR you want printed at the start of every table, and at the top of every page when a table is interrupted by a page-break. Typically a THEAD's single TR (you can have more than one, but it rarely makes sense) contains TH.

    TFOOT is THEAD's counterpart -- it prints at the end of the table, and at the bottom of every page when a table is interrupted by a page-break.

    TBODY is your actual data rows.

    There's also that SCOPE attribute I used -- should be pretty clear what it does, it declares if the heading cell is for the row or the column.

    It's actually funny, I'd guesstimate (pulling a number out my backside based on experience) that 90% or more developers still are unaware there are even tags other than TR and TD that go in a table.

    Quote Originally Posted by 12Strings View Post
    I'm not sure about your last line
    By default IE and FF both override your print.css with their own settings and play mix-match with values from the screen.css -- it's one of the reasons (along with handhelds pulling similar games) that media targets (the values for the MEDIA attribute on LINK) were semi-undeployable. The problem wasn't the specification, it was the two main browsers during the first decade of HTML 4 basically ignoring that there even was a specification.

    Laughably, FF still has massive gaps in how it handles HTML 4 -- which of course is why they're implementing HTML 5 garbage first. :/
    Last edited by deathshadow; 05-21-2014 at 11:39 PM.

  5. #5
    Join Date
    Apr 2013
    gastonia NC
    thanks a lot , u mentioned a text editor to use multiple windows. how about pointing to one?

  6. #6
    Well the one I use is called "Flo's Notepad 2

    It's based on Scintilla (while not being a total piece of Scite) so it has pretty much every feature you'd expect a programmers editor to have, but without the massive step backwards in functionality that is shoving all the editor boxes into a single window. I like it because it also lets me turn off all the garbage that annoys me -- like auto-closing markup, colour syntax highlighting, and all that other crap that just makes coding HARDER... while still providing useful things like line-wrap indicators, line-wrap indenting, changing the default tab size, long line guide, and the typical plethora of search, brace matching, replace and 'block conversion' functions, single file instances (so you don't accidentally open a new copy of the same file).

    Actually finding editors that aren't tabbed and shove everything into one window is kind-of hard. Even the ones that let you 'detach' a tab (like classic Opera's MDI used to let you) don't use open in a new window as the default behavior; the list gets pretty short. Flo's, Win32pad... and... regular plain-jane notepad. I can't even think of any others that allow for it.

    Really Flo's Notepad2 is the best programming editor I've ever used -- and I've tried a LOT of them the past three and a half decades... I say it's the best BECAUSE it doesn't load up on features I'm never going to use or just get in my blasted way. I say it's the best because honestly, I can't fathom a legitimate reason for them to ever issue a new version other than if it breaks in a new version of Windows.

    Some things should be simple enough -- like text editors -- you shouldn't need a new version every fifteen minutes.

  7. #7
    Join Date
    Apr 2013
    gastonia NC
    are u referring 2 notepade++? I discovered it some time ago and use it 2 keep track of line#s.

  8. #8
    Join Date
    Aug 2004
    Choosing the "best" code editor is like choosing the "best" programming language or the "best" framework: get 20 random developers in a room, and you'll have approximately 19 suggestions for each.

    I've been on Komodo Edit for a couple years now, but who knows what I'll be using in another year? (And sometimes, when I'm in a hurry and I'm on a Linux VM, I just type vi filename.php . )
    Last edited by NogDog; 05-22-2014 at 08:25 PM.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  9. #9
    Quote Originally Posted by 12Strings View Post
    are u referring 2 notepade++? I discovered it some time ago and use it 2 keep track of line#s.
    No, I linked to what I'm referring to. "Flo's Notepad 2" -- AGAIN:

    Notepad++ is a fine program, but it's inability to default to non-tabbed editing, painfully slow (to me) loading time, and endless bloated nonsense I'd never actually use when writing code; much less the massive amount of stuff I'd have to turn off before even STARTING to use it, is why I rejected it. People who need the crutches and training wheels seem to like it though. I think I really gave up on it when I couldn't figure out how to get rid of the idiotic space wasting tab interface and toolbar garbage... but I'm wierd, the only things I want to see is a status bar at the bottom, filename as the window frame title, and a old-fashioned text menu. Like I'm supposed to know what all those crappy little icons are even supposed to mean? Much less if you're set to single instance, what the **** does it need a tab bar for?

    Quote Originally Posted by NogDog View Post
    Choosing the "best" code editor is like choosing the "best" programming language or the "best" framework: get 20 random developers in a room, and you'll have approximately 19 suggestions for each.
    True enough -- otherwise we wouldn't have dozens if not hundreds of different ones to choose from. Things that piss me off -- like autocomplete, autoclosures, space wasting 'false simplicity' toolbars, the illegible acid trip known as colour syntax highlighting, tabs - might be the bee's knees to someone else.

    See the people who find vi/vim or emacs to be 'the best', while I sit here wondering just what the **** they are smoking.

    Quote Originally Posted by NogDog View Post
    I've been on Komodo Edit for a couple years now
    To me the 70 megabyte download was a warning it would be a giant steaming pile I wouldn't want to use; but it's more of an IDE, which to me is just a waste of time and effort, and usually eats up screen real-estate with crap I don't want or need.

    Once installed the ridiculously long startup time, oddball toolbar enabling/disabling that is near impossible to restore should you accidentally turn off the 'normal' menu, goofy "overview" thing on the side I could never figure out how to disable, even goofier "start page" and stupid "project management" crap, etc, etc... is exactly what I mean by garbage that just gets in the way of *SHOCK* sitting down and just writing some code.

    Of course that it forces EVERYTHING into a single window without the means to detach the tabs or run as single instances makes it useless to me as a multiple display user... or even on a widescreen. It's a poster child for everything wrong (IMHO) with so called "IDE's".

    Me? I just want to *SHOCK* open a bloody window and edit some plaintext. IDE's and some of the fancier plain editors have all this extra garbage that just gets in the way of that... which is why I use a basic notepad replacement regardless of if I'm writing Pascal, C, assembler, PHP, JS, HTML or CSS. If you need anything more, you probably don't have the skills to be writing code in the first place.

    Hell, if Notepad had proper character set conversion capabilities, tab/space conversions, and regex for search/replace -- I'd probably still be using plain-Jane notepad.
    Last edited by deathshadow; 05-22-2014 at 10:06 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.12435 seconds
  • Memory Usage 2,983KB
  • Queries Executed 15 (?)
More Information
Template Usage (34):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (3)bbcode_code
  • (8)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (9)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates