Remember that databases, e.g., MySQL, have no concept of "page", so passing both page # AND cursor $iCursor = $_GET // get actual cursor value If (!empty($_GET)) // cursor passed via GET $iPageNum = $_GET // get actual page number If (!empty($_GET)) // page number passed via GET If ($RANGE % 2 = 0) // calculate modulo only once for both constants $iRangeMax = (int) ($RANGE % 2 = 0) ? $iRangeMin + 1 : $iRangeMin // Dagon's elegant original calculate local control constants (could/should be precalculated and stored as CONSTANTS in. $RANGE = 10 // number of page numbers in pageBar (set by you) $ROWCOUNT = 25 // # rows per page (set by you) Ini_set("track_errors", "1") // error trackingĮrror_reporting(E_ALL) // enable error notices strongly advisable during code development and debugging! set php configuration variables to illustrate strict compliance $_sMsg = (string) date("j F Y, g:i a: ") Įrror_log($_sMsg, 3, "errors.log") // change to direct output to your preferred log file location string $sMessage => string to be written to error log here's a simple error logging function to facilitate debugging (aka, "instrumentation") download/rendering, which is just fine for my clients since my sites are working sites not consumer-oriented marketing hoses. My goal is not glitz but fast-as-possible visitor/guest/user access is controlled at both application AND page levels. especially when it relates to site security: all of my site pages are generated dynamically, and, more importantly, If anything, my standards are higher today than ever before, PHP+MySQL+HTML code using these conventions. However, I have built, and daily maintain, 7 APACHE+PHP+MySQL websites, comprising tens of thousands of lines of My coding conventions will not appeal to all, but opinions are rather like, uh, noses. - all HTML generated by this script has been "prettified" to make it easier to read/debug - all HTML tags are balanced and full lower case per the W3C standard left align language shift constructs to make them easily identifiable (contrast, e.g., lines 1 and 142, and line 167) - maintain separate and distinct tabbing sequences for PHP and HTML code snippets, and, except for embedded snippets, - leading tabs rather than spaces (marginally faster to parse) - this one is controversial - C++ style comments, with in-line preferred whenever possible =" doesn't work (so, for consistency, NEVER use spaces for the.operator) - for clarity, all operators have leading and trailing spaces, If ( ($this->page_num > ($range - $range_min)) & ($numofpages > $range) ) are ALWAYS on separate lines AND lined up vertically to make balancing visually easy $page_min = ($page_min > 1) ? $numofpages - $range + 1 : 1 $range_max = ($range % 2 = 0) ? $range_min + 1 : $range_min Perhaps a little raw for you - but this is what i use in dozen of places to do that
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |