RE: [PHP] Paged Results Set in MySQL DB with one result
tedd mailto:[EMAIL PROTECTED] on Friday, May 12, 2006 12:23 PM said: That's as it should be -- and technically, Next did appear so the page wasn't blank. Splitting hairs aside, a user, civilian or not, would not expect they need to click Next from a blank page to get to the content they are looking for. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
At 5:06 PM -0500 5/11/06, Richard Lynch wrote: On Thu, May 11, 2006 1:20 pm, tedd wrote: Does this qualify? http://xn--ovg.com/ajax_page Well, on page 1, I can't get it to re-size at all... So, no, it doesn't qualify. :-) You didn't say it must be re-sizable. Okay, let me get this right. If the page could be resized, and the text would dynamically fill the space, and the user could step through the text like a reader, then would that qualify? Keep in mind that you can have it one of two ways (mutually exclusive). One, static page -- a page is what you see and each time to return to that page it's exactly as it looked before. Two, dynamic page -- when you re-size the page, One is no longer applicable. I just gave you One, now you want Two? I believe the OP wanted Three: Show only as much text as nicely fits in the browser, with more for the next page... So, the page is fluid, uses the entire browser window, and has a more button -- right? Will that do it? tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
At 5:06 PM -0500 5/11/06, Richard Lynch wrote: I believe the OP wanted Three: Show only as much text as nicely fits in the browser, with more for the next page... Try this: http://xn--ovg.com/ajax_page1 Please understand: a) It's a rough estimation as to how many characters will fit; b) It doesn't handle zoom levels well yet; c) There will be variations between browsers and OS's -- but the solution is within reach. tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
tedd [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Try this: http://xn--ovg.com/ajax_page1 Please understand: a) It's a rough estimation as to how many characters will fit; b) It doesn't handle zoom levels well yet; c) There will be variations between browsers and OS's -- but the solution is within reach. Eerrrm... Blank Page!?! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
I am not seeing a blank page here. Porpoise wrote: tedd [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Try this: http://xn--ovg.com/ajax_page1 Please understand: a) It's a rough estimation as to how many characters will fit; b) It doesn't handle zoom levels well yet; c) There will be variations between browsers and OS's -- but the solution is within reach. Eerrrm... Blank Page!?! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
At 6:03 PM +0100 5/12/06, Porpoise wrote: tedd [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Try this: http://xn--ovg.com/ajax_page1 Please understand: a) It's a rough estimation as to how many characters will fit; b) It doesn't handle zoom levels well yet; c) There will be variations between browsers and OS's -- but the solution is within reach. Eerrrm... Blank Page!?! It shouldn't be blank. There should be a Next/Previous button -- isn't there? If so, then click Next If not, please tell me. Thanks. tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
In Exploder 7 beta 2 I actually get an access denied error... but works in firefox. Mike wrote: I am not seeing a blank page here. Porpoise wrote: tedd [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Try this: http://xn--ovg.com/ajax_page1 Please understand: a) It's a rough estimation as to how many characters will fit; b) It doesn't handle zoom levels well yet; c) There will be variations between browsers and OS's -- but the solution is within reach. Eerrrm... Blank Page!?! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
On Friday 12 May 2006 12:01 pm, tedd wrote: It shouldn't be blank. There should be a Next/Previous button -- isn't there? If so, then click Next If not, please tell me. Works: Suse Linux 10.x/Firefox 1.0.7 Windows XP/Firefox 1.5.0.3 Mac OS 10.4.6/Safari 2.0.3 Works sort of: Suse Linux 10.x/Konquerer 3.4.2 = (first page loads but next/previous buttons produce no results) Windows XP/Internet Explorer 6.0.x = (first page loads but next/previous buttons produce no results) Blank: none that I tested Don't have Firefox on the Mac box. I just clicked the next/previous buttons a few times, so take it for what's it's worth. Thanks to you Tedd. Made me realize I should upgrade my Linux Firefox. HTHs. -- Joe Henry www.celebrityaccess.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Paged Results Set in MySQL DB with one result
tedd mailto:[EMAIL PROTECTED] on Friday, May 12, 2006 11:01 AM said: At 6:03 PM +0100 5/12/06, Porpoise wrote: tedd [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Try this: http://xn--ovg.com/ajax_page1 Eerrrm... Blank Page!?! It shouldn't be blank. There should be a Next/Previous button -- isn't there? If so, then click Next If not, please tell me. I got a blank page too. Had to click Next before any content would appear. Fx 1.5.0.3 on Windows 2000 Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
At 2:08 PM -0400 5/12/06, Brad Bonkoski wrote: In Exploder 7 beta 2 I actually get an access denied error... but works in firefox. I think that's my server. Ajax is strange -- the requests are not sequential. In other words, if you click next twice, you may end up with the first click appearing second. Also, I'm having problems calling a refresh routine that should work. But, if anything is going to fail, it's IE's. I probably could run down the problem in IE7 and place a IE conditional to circumvent the problem. tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Paged Results Set in MySQL DB with one result
At 11:51 AM -0700 5/12/06, Chris W. Parker wrote: tedd mailto:[EMAIL PROTECTED] on Friday, May 12, 2006 11:01 AM said: At 6:03 PM +0100 5/12/06, Porpoise wrote: tedd [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Try this: http://xn--ovg.com/ajax_page1 Eerrrm... Blank Page!?! It shouldn't be blank. There should be a Next/Previous button -- isn't there? If so, then click Next If not, please tell me. I got a blank page too. Had to click Next before any content would appear. Fx 1.5.0.3 on Windows 2000 Chris. That's as it should be -- and technically, Next did appear so the page wasn't blank. I probably should put up a Introduction page, which would tell people to click something, but this was just a test. If it had been a production open to the world thing, then I would have written it for civilians. tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
tedd [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] At 6:03 PM +0100 5/12/06, Porpoise wrote: Eerrrm... Blank Page!?! It shouldn't be blank. There should be a Next/Previous button -- isn't there? If so, then click Next If not, please tell me. Err. Well, yes the Previous/Next buttons are there.. but there's no data. Clicking Next doesn't achieve anything AFAICS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
At 8:35 PM -0500 5/4/06, Richard Lynch wrote: Synopsis: You could just Javascript and browser info to dynamically layout text to fit available space and word-wrap nicely. Find me anybody on the planet who has actually successfully done this. Even easier: Point to ONE existing website that successfully does this. Cuz I can find about a thousand very sharp folks who tried, and failed... And I don't think I've ever seen one who succeeded, in a cross-platform way that actually works... But maybe I've just missed the boat. Has been known to happen. :-) Does this qualify? http://xn--ovg.com/ajax_page It's just the first seven pages of the Bible. If I could figure out how to upload the entire kjv into MySQL, I would. tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
On Thu, May 11, 2006 10:09 am, tedd wrote: At 8:35 PM -0500 5/4/06, Richard Lynch wrote: Synopsis: You could just Javascript and browser info to dynamically layout text to fit available space and word-wrap nicely. Find me anybody on the planet who has actually successfully done this. Even easier: Point to ONE existing website that successfully does this. Cuz I can find about a thousand very sharp folks who tried, and failed... And I don't think I've ever seen one who succeeded, in a cross-platform way that actually works... But maybe I've just missed the boat. Has been known to happen. :-) Does this qualify? http://xn--ovg.com/ajax_page Well, on page 1, I can't get it to re-size at all... So, no, it doesn't qualify. :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
Does this qualify? http://xn--ovg.com/ajax_page Well, on page 1, I can't get it to re-size at all... So, no, it doesn't qualify. :-) You didn't say it must be re-sizable. Okay, let me get this right. If the page could be resized, and the text would dynamically fill the space, and the user could step through the text like a reader, then would that qualify? Keep in mind that you can have it one of two ways (mutually exclusive). One, static page -- a page is what you see and each time to return to that page it's exactly as it looked before. Two, dynamic page -- when you re-size the page, One is no longer applicable. I just gave you One, now you want Two? tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
Richard Lynch [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Thu, May 11, 2006 10:09 am, tedd wrote: At 8:35 PM -0500 5/4/06, Richard Lynch wrote: But maybe I've just missed the boat. Has been known to happen. :-) Does this qualify? http://xn--ovg.com/ajax_page Well, on page 1, I can't get it to re-size at all... So, no, it doesn't qualify. :-) hmmm well, I can get it to resize but it resizes the whole iframe and doesn't re-flow the text to retain iframe size - so it messes up the screen layout somewhat. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
On Thu, May 11, 2006 1:20 pm, tedd wrote: Does this qualify? http://xn--ovg.com/ajax_page Well, on page 1, I can't get it to re-size at all... So, no, it doesn't qualify. :-) You didn't say it must be re-sizable. Okay, let me get this right. If the page could be resized, and the text would dynamically fill the space, and the user could step through the text like a reader, then would that qualify? Keep in mind that you can have it one of two ways (mutually exclusive). One, static page -- a page is what you see and each time to return to that page it's exactly as it looked before. Two, dynamic page -- when you re-size the page, One is no longer applicable. I just gave you One, now you want Two? I believe the OP wanted Three: Show only as much text as nicely fits in the browser, with more for the next page... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
On May 4, 2006, at 11:16 PM, Jochem Maas wrote: Richard Lynch wrote: On Thu, May 4, 2006 10:15 am, Edward Vermillion wrote: On May 4, 2006, at 4:16 AM, Richard Lynch wrote: On Wed, May 3, 2006 6:57 pm, Jochem Maas wrote: ... Yes. Usually. Mostly sometimes. For something like a Forum or a CMS with minimal EZ tags for the admin on a small-scale site, I'll confess to just tossing HTML into the db. But not if my site is allegedly a professionally-written series of articles. lets assume that the author of the articles what some kind of stylistic and/or semantic control over the content of the article - how would you store this formatting information? I'd hazard to say that XHTML is a rather better markup language definition than any custom thing we could come up with on own own, no? Your probably right, well at least defining a custom xml dtd set for your particular purposes, or not, maybe. I haven't gotten into the whole XML thing yet, so I could very well change my mind once I do (in other words, I know what I know so if I'm being a complete idiot slap me over the head). The problem I have with using X/HTML in the body of the articles is that it's a lot more difficult, at least for me, to control what gets in and what doesn't. script... for example (or sc ri pt.. which apparently IE is more than happy to execute for you). I'd rather define a *small* set of custom tags that look nothing like X/ HTML that I do a replacement on after running htmlentities() on the text. That way if for some unknown reason they want to have img or link or script or just ? in the body of the text, it shows up fine and it doesn't break anything. If the replacement tag gets borked then you see parts of the tag, and the page still isn't broken. As a personal note, I prefer to read things that have been broken up into logical chunks for me, as opposed to being fed some 2000 word essay all at once. I *hate* scrolling. But then I didn't learn to read on a computer screen either. There's truly logical chunks, and there's we need you to break this into 10 pages so we can sell more ads, okay? chunks. lol - don't forget the chunk it so we sell more banners AND link random words in the article to DHTML popup ads - I *really* hate those. Blech. I assumed logical chunks, hadn't even thought of marketing getting in on the action... *eww* Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
Miles Thompson wrote: At 03:51 PM 5/3/2006, Phillip S. Baker wrote: Greetings Gents, ... However - why do you think paging an article improves readability? What it does do is control the amount of text you display on a page so you can profitably surround it with advertising. It has no effect on readabilty -- that depends on the quality of the writing, clarity and size of font, and line length. So, give them good dynamic design, a legible font, the ability to resize the type and ensure that the pieces are well-edited and written for easy reading in a browser. Guess I'm an iconoclast, but when I see an artificially paged article I look for the Print View link so I can read it all at once. Heresy! Maybe that's another reason for paging -- you get more hits on the site. Guess this has been more like a semi-rant, and probably not helpful. g on the contrary you gave arguments based on real world experience. and when I think about it, sites like 'A list Apart' spring to mind and I can't help thinking that you have a really good point. nice one :-) Cheers - Miles -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
On Wed, May 3, 2006 1:51 pm, Phillip S. Baker wrote: I have an interesting problem I would like some ideas on for a solution. I cannot seem to find any code examples on the net, though I might not be looking in the right place really. I have some articles stored in a MySQL DB. What I want is if the article is above a certain length in characters, to page article through a few pages for site readability. So I would want to print X number of words/characters. Save the where the pointer is, move on to the next page, and display the same amount and so on for as many pages as needed. I know about pulling paged results using the limit function but that would not seem to apply as really I would want to page the results within one record (one field really). It's pretty much the same as paging through records, but instead of: LIMIT $limit OFFSET $offset you would do: SELECT substring(monster_text, $offset, $limit) FROM whatever You will probably then want to dink around with things so that you don't break your text up in mid-word, but you can do that fairly easy on the PHP end once you have the chunk of text with http://php.net/strrpos: $pos = strrpos($text, ' '); $next_offset = $offset + $limit - ($limit - $pos); $text = substr($text, 0, $pos); There's probably an off-by-one error in that, but you get the idea. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
On Wed, May 3, 2006 6:57 pm, Jochem Maas wrote: a. who said anything about sessions? Jay did. He suggested sucking down the whole article, paginating it all, and cramming the pages into session, presumably so you don't have to suck down the whole article again. Which, by the way, is what I dislike about most of these answers... If the article is REALLY big, a query to get the whole damn thing is slow. parsing for html comments that could get blasted by an errant edit. the marker is either there or not - and if it'd borked (e.g. '!-- PAGE MAR') then it would break the page, sure - but so could ANY broken markup so the argument is somewhat moot. besides a routine to strip markers (broken or otherwise) is as simple to write as marker splitting function is. I think the assumption is that the article is actually HTML in the databse... At which point, almost any pagination you try to do programmatically is just plain borked. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
Richard Lynch wrote: On Wed, May 3, 2006 6:57 pm, Jochem Maas wrote: a. who said anything about sessions? Jay did. dang - I didn't read properly - apologies go out to Edward for that! He suggested sucking down the whole article, paginating it all, and cramming the pages into session, presumably so you don't have to suck down the whole article again. Which, by the way, is what I dislike about most of these answers... If the article is REALLY big, a query to get the whole damn thing is slow. agreed - but then caching concepts/implementations of content/data/etc belongs on a whole other level imho. parsing for html comments that could get blasted by an errant edit. the marker is either there or not - and if it'd borked (e.g. '!-- PAGE MAR') then it would break the page, sure - but so could ANY broken markup so the argument is somewhat moot. besides a routine to strip markers (broken or otherwise) is as simple to write as marker splitting function is. I think the assumption is that the article is actually HTML in the databse... I made the same assumption. At which point, almost any pagination you try to do programmatically is just plain borked. absolutely - assuming the programmic pagination is based on 'logic' as opposed to being based on 'commands' (i.e. specific markers) put in place by the author of said article (whihc to me equates to putting seperate 'pages' in seperate records in the DB because the pagination is explicit rather than inferred). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
At 11:51 AM 5/3/2006, Phillip S. Baker wrote: I have some articles stored in a MySQL DB. What I want is if the article is above a certain length in characters, to page article through a few pages for site readability. So I would want to print X number of words/characters. Save the where the pointer is, move on to the next page, and display the same amount and so on for as many pages as needed. Phillip, There's a fundamental problem with trying to slice text into resizable web pages the same way it's sliced on paper. Paper pages work because they're set in a fixed font size. When you change the ratio of font size to column width, the places where lines of text wrap changes. Because of the varying lengths of words, strings of words spill over to the next line in non-linear rates. Unless you use a fixed font size (boo, hiss) or you change the font size and the column width at exactly the same rate by sizing your layout in ems, your text columns are going to change in height (line-count) with font resizing. This means that the amount of text that fits on a page changes dynamically with browser events and cannot be predicted or controlled server-side by PHP -- unless you can accept a layout sized in ems both horizontally and vertically, which few people seem willing to do, or you force your readers to accept your choice of font size, which would be an ironic and depressing decision for a modern publisher to make. Here's a related problem: Say you calculate the number of words that can fit in N column inches and dish out that much text from your database, and let's say that the last line on the page is in mid-paragraph. When the user resizes their browser font, the word-wrap will change and suddenly the last line on the page will end halfway across the column even though it isn't the end of the sentence or the paragraph. In addition, all this means dynamically changing widows and orphans, also of concern to the serious typographer. As a final coup de grace, any calculation of words per line must take into account the metrics of the specific font being rendered, a practical impossibility when fonts are selected from the users' computers and not the publisher's. While PHP and MySQL can supply the raw text from the server, these issues beg for a client-size solution at the reader's end. My first choice of solution would be to size my columns in ems to allow the entire layout to zoom both horizontally and vertically with font-size, in which case your problem of how to extract contiguous text strings again becomes relevant. And that's trivial, really, compared to the algorithm you'll have to write to predict how many words will wrap into a given number of lines when you can't even predict the font being used. You could make the problem much more solvable by dishing up whole paragraphs only, and learning to accept (nay, embrace!) the resultant variation in page-length. Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Paged Results Set in MySQL DB with one result
[snip] There's a fundamental problem with trying to slice text into resizable web pages the same way it's sliced on paper. Paper pages work because they're set in a fixed font size. When you change the ratio of font size to column width, the places where lines of text wrap changes. Because of the varying lengths of words, strings of words spill over to the next line in non-linear rates. Unless you use a fixed font size (boo, hiss) or you change the font size and the column width at exactly the same rate by sizing your layout in ems, your text columns are going to change in height (line-count) with font resizing. More [/snip] Paul states here more eloquently what I hinted at in my response in terms liquid layouts, et. al. You must quit thinking of web pages in print pages terms, a concept which may be more difficult than arrays. Also, Jochem made a statement about allowing authors to determine logical page breaks in their tomes, and he is correct. You'll see that articles on Evolt, A List Apart, SitePoint and others are broken logically (almost in chapters). This would be preferred. I did use an array and sessions in my example because I want to save round trips to the database. Using Jochem's suggestion with an HTML comment you can achieve the same thing by placing the chunks of the article between the comments into session variables. The wheel here has been created many times and many ways. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
At 4:30 AM -0700 5/4/06, Paul Novitski wrote: At 11:51 AM 5/3/2006, Phillip S. Baker wrote: I have some articles stored in a MySQL DB. What I want is if the article is above a certain length in characters, to page article through a few pages for site readability. So I would want to print X number of words/characters. Save the where the pointer is, move on to the next page, and display the same amount and so on for as many pages as needed. Phillip, There's a fundamental problem with trying to slice text into resizable web pages the same way it's sliced on paper. Paper pages work because they're set in a fixed font size. When you change the ratio of font size to column width, the places where lines of text wrap changes. Because of the varying lengths of words, strings of words spill over to the next line in non-linear rates. Unless you use a fixed font size (boo, hiss) or you change the font size and the column width at exactly the same rate by sizing your layout in ems, your text columns are going to change in height (line-count) with font resizing. -snip- (good stuff) You could make the problem much more solvable by dishing up whole paragraphs only, and learning to accept (nay, embrace!) the resultant variation in page-length. Paul Paul et al: If the text is organized into paragraphs, which I can't imagine it not being, then the solution can be found in using a combination of javascript and php. Javascript can detect the size (height width) of window the user is currently using and the web site has control over the font size and margins. With that information, via ajax, it's certainly solvable to calculate what text would fit into the space provided and display it in real time. Granted it would make for a boring presentation because no titles or variations in font sizes, but if someone wanted to simply throw text to an open window, one could calculate how many paragraphs would fit in the available space and the users actions (on-load, window-resize) could trigger the operation. Furthermore, if headings where identifiable, then those could be thrown into the mix and calculated as well. tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
On May 4, 2006, at 4:16 AM, Richard Lynch wrote: On Wed, May 3, 2006 6:57 pm, Jochem Maas wrote: a. who said anything about sessions? Jay did. He suggested sucking down the whole article, paginating it all, and cramming the pages into session, presumably so you don't have to suck down the whole article again. Which, by the way, is what I dislike about most of these answers... If the article is REALLY big, a query to get the whole damn thing is slow. That was my thought. Plus if the user closes the browser you loose the session(usually, for anonymous sessions, not logged in users), then you have to do the processing/session storing all over again if they wanted to look at it again right away. Multiply by a couple thousand and your server is doing a lot of work it really doesn't have to if the 'pages' are pre-set and you're only grabbing a small chunk at a time. Plus you can get relevant urls to a 'page' that can be bookmarked, to a degree. Aside from not having to do a lot of text processing, the queries would be simpler too. And the author would still have control over the length of the 'pages', which is probably much preferable to some kind of automatic system that has no concept of context. I'm not saying all of the 'pages' would be exactly the same length, but they would make sense as pages when you read them, if the author knew what they were doing. parsing for html comments that could get blasted by an errant edit. the marker is either there or not - and if it'd borked (e.g. '!-- PAGE MAR') then it would break the page, sure - but so could ANY broken markup so the argument is somewhat moot. besides a routine to strip markers (broken or otherwise) is as simple to write as marker splitting function is. I think the assumption is that the article is actually HTML in the databse... I wasn't making that assumption. define('HTML_stored_in_the_DB_for_dynamic_content', 'bad'); // IMHO :) What if you write a cool pdf generator (or rss feed or whateverNewThingComesAlong) in a couple years to deliver those articles? Wouldn't it be easier to adapt a tag replacer that you already have ( because you're not storing the html, and folks want to be able to make a word bold in the web page 'cause they can do it in MSWord :P) to other formats than try to write an html parser from scratch? (Yeah, I know that you still have the danger of users borking the replacement tags, no idea is perfect) Plus having easy access to 'sections' of articles means that those sections aren't necessarily tied to a particular article. Mix and match(repurpose) anyone? As a personal note, I prefer to read things that have been broken up into logical chunks for me, as opposed to being fed some 2000 word essay all at once. I *hate* scrolling. But then I didn't learn to read on a computer screen either. Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
At 07:12 AM 5/4/2006, tedd wrote: If the text is organized into paragraphs, which I can't imagine it not being, then the solution can be found in using a combination of javascript and php. Javascript can detect the size (height width) of window the user is currently using and the web site has control over the font size and margins. With that information, via ajax, it's certainly solvable to calculate what text would fit into the space provided and display it in real time. Granted it would make for a boring presentation because no titles or variations in font sizes, but if someone wanted to simply throw text to an open window, one could calculate how many paragraphs would fit in the available space and the users actions (on-load, window-resize) could trigger the operation. Furthermore, if headings where identifiable, then those could be thrown into the mix and calculated as well. Yes: cutting text into arbitrary column-lengths is most likely a client-side task and therefore not on-topic for this list, but since you've opened the door... Headlines and other variations in text size need not be a problem. No need to calculate rendered text size: let the browser do it. The way I might approach this is to feed more text to the page than I know will fit, enclose it in a container that JavaScript sets to {overflow: hidden}, and use JavaScript to detect where (at which paragraph and word) the visible text block ends. One way to find the last visible word would be to enclose a word in a span, compare its rendered position to the height of the text container, remove the span, and continue until we find a word that's lower than the bottom of the container. The most efficient way to perform this search might be to check the first word of each paragraph until a hidden word is found, then work backward from there. Once JavaScript had determined the last word on the rendered page (or the first word to be displayed on the next page), it would communicate this to PHP -- either immediately [via new Image() src or XMLHttpRequest] or on the next page request through the navigation hyperlinks or form submit. To accommodate font-resizing, JavaScript could set a self-timer to re-check the last visible first hidden words on the page and see if their 'shown' status had changed. If it has, all it has to do is report the new page boundary to PHP. This would have to work in the absence of client-side scripting, so it's JavaScript that sets {overflow: hidden} on the text container. This technique could also be used to flow text across multiple columns. I don't know how close it comes to existing techniques of calculating text-column-length. In my Copious Spare Time I'll do a proof of concept to see how this flies. Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
On Thu, May 4, 2006 9:12 am, tedd wrote: [snip] Synopsis: You could just Javascript and browser info to dynamically layout text to fit available space and word-wrap nicely. Find me anybody on the planet who has actually successfully done this. Even easier: Point to ONE existing website that successfully does this. Cuz I can find about a thousand very sharp folks who tried, and failed... And I don't think I've ever seen one who succeeded, in a cross-platform way that actually works... But maybe I've just missed the boat. Has been known to happen. :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
On Thu, May 4, 2006 10:15 am, Edward Vermillion wrote: On May 4, 2006, at 4:16 AM, Richard Lynch wrote: On Wed, May 3, 2006 6:57 pm, Jochem Maas wrote: the marker is either there or not - and if it'd borked (e.g. '!-- PAGE MAR') then it would break the page, sure - but so could ANY broken markup so the argument is somewhat moot. besides a routine to strip markers (broken or otherwise) is as simple to write as marker splitting function is. I think the assumption is that the article is actually HTML in the databse... I wasn't making that assumption. Actually, I wasn't either, initially... define('HTML_stored_in_the_DB_for_dynamic_content', 'bad'); // IMHO :) Yes. Usually. Mostly sometimes. For something like a Forum or a CMS with minimal EZ tags for the admin on a small-scale site, I'll confess to just tossing HTML into the db. But not if my site is allegedly a professionally-written series of articles. As a personal note, I prefer to read things that have been broken up into logical chunks for me, as opposed to being fed some 2000 word essay all at once. I *hate* scrolling. But then I didn't learn to read on a computer screen either. There's truly logical chunks, and there's we need you to break this into 10 pages so we can sell more ads, okay? chunks. Blech. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
Richard Lynch wrote: On Thu, May 4, 2006 10:15 am, Edward Vermillion wrote: On May 4, 2006, at 4:16 AM, Richard Lynch wrote: On Wed, May 3, 2006 6:57 pm, Jochem Maas wrote: ... Yes. Usually. Mostly sometimes. For something like a Forum or a CMS with minimal EZ tags for the admin on a small-scale site, I'll confess to just tossing HTML into the db. But not if my site is allegedly a professionally-written series of articles. lets assume that the author of the articles what some kind of stylistic and/or semantic control over the content of the article - how would you store this formatting information? I'd hazard to say that XHTML is a rather better markup language definition than any custom thing we could come up with on own own, no? As a personal note, I prefer to read things that have been broken up into logical chunks for me, as opposed to being fed some 2000 word essay all at once. I *hate* scrolling. But then I didn't learn to read on a computer screen either. There's truly logical chunks, and there's we need you to break this into 10 pages so we can sell more ads, okay? chunks. lol - don't forget the chunk it so we sell more banners AND link random words in the article to DHTML popup ads - I *really* hate those. Blech. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Paged Results Set in MySQL DB with one result
[snip] Does anyone have any ideas?? [/snip] Quite frankly, yes. Question is, how many words do you want to show up on a 'page'? Is the design liquid or rigid? A basic formula (pseudo-code, will not actually work in the PHP parser); Select article body from database. Place all of the words in an array. Count the array. Divide that number by the number of words you wish to appear in a page. Split the array into the chunks described by the math. Place each chunk into a session variable. If the variable is identified as being the one to be displayed for this page, do it...if not, don't. Easy-peasy lemon squeezy, no? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
Phillip S. Baker wrote: Greetings Gents, I have an interesting problem I would like some ideas on for a solution. I was going to make a comment about the use of 'interesting' but thought better of it. ;-) I cannot seem to find any code examples on the net, though I might not be looking in the right place really. I have some articles stored in a MySQL DB. What I want is if the article is above a certain length in characters, to page article through a few pages for site readability. So I would want to print X number of words/characters. Save the where the pointer is, move on to the next page, and display the same amount and so on for as many pages as needed. I know about pulling paged results using the limit function but that would not seem to apply as really I would want to page the results within one record (one field really). Does anyone have any ideas?? I'm with Jay on the ideas front, here is mine: ON THE EDITING SIDE: 1. use a customizable wysiwyg web based editor to edit your articles. 2. add a button called 'page break' that inserts something like '!-- PAGEBREAK (notice I made it an HTML comment - that's handy, you can hopefully see why) ON THE DISPLAY SIDE: 1. grab the [formatted] text for the item/article in question. 2. split the text on the string you button injects into the content determine the selected page (via GET param or something like that) into an array 3. find the the array item corresponding the requested 'article page' 4. display the array item from point 3. the philosphy is that any half-baked article author will know much better where to place a 'page break' than any code you could write - because it comes down to trying to automate DTP/design - which AFAIC only a human can do properly. Thanks Phillip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
Or just break the page up into sections and grab subsequent sections from the DB. (?) That way you could easily code in a 'jump to page 3 from page 6' type function, and your still just grabbing data and spitting it out with out worrying about sessions getting mangled or parsing for html comments that could get blasted by an errant edit. Ed On May 3, 2006, at 5:25 PM, Jochem Maas wrote: Phillip S. Baker wrote: Greetings Gents, I have an interesting problem I would like some ideas on for a solution. I was going to make a comment about the use of 'interesting' but thought better of it. ;-) I cannot seem to find any code examples on the net, though I might not be looking in the right place really. I have some articles stored in a MySQL DB. What I want is if the article is above a certain length in characters, to page article through a few pages for site readability. So I would want to print X number of words/characters. Save the where the pointer is, move on to the next page, and display the same amount and so on for as many pages as needed. I know about pulling paged results using the limit function but that would not seem to apply as really I would want to page the results within one record (one field really). Does anyone have any ideas?? I'm with Jay on the ideas front, here is mine: ON THE EDITING SIDE: 1. use a customizable wysiwyg web based editor to edit your articles. 2. add a button called 'page break' that inserts something like '!-- PAGEBREAK (notice I made it an HTML comment - that's handy, you can hopefully see why) ON THE DISPLAY SIDE: 1. grab the [formatted] text for the item/article in question. 2. split the text on the string you button injects into the content determine the selected page (via GET param or something like that) into an array 3. find the the array item corresponding the requested 'article page' 4. display the array item from point 3. the philosphy is that any half-baked article author will know much better where to place a 'page break' than any code you could write - because it comes down to trying to automate DTP/design - which AFAIC only a human can do properly. Thanks Phillip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
Edward Vermillion wrote: Or just break the page up into sections and grab subsequent sections from the DB. (?) that, or any number of other ideas. but I know from experience that offering seperate records for each section generally leads to a less intuitive (read: easy to use) editing interface (or conversely an editing interface that is alot more work to build). That way you could easily code in a 'jump to page 3 from page 6' type function, you could/can do that anyway, if you have 'sectioned' content regardless of whether you create the sections programatically (as Jay suggested), parse the content for section markers or (as I suggested) or stuff 'section' into DB records (as you suggested) and your still just grabbing data and spitting it out with out worrying about sessions getting mangled or a. who said anything about sessions? b. exactly when do sessions getting mangled? c. you can't code with a few possible error situation in mind? d. what happens when your DB goes down? parsing for html comments that could get blasted by an errant edit. the marker is either there or not - and if it'd borked (e.g. '!-- PAGE MAR') then it would break the page, sure - but so could ANY broken markup so the argument is somewhat moot. besides a routine to strip markers (broken or otherwise) is as simple to write as marker splitting function is. jmho. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
At 03:51 PM 5/3/2006, Phillip S. Baker wrote: Greetings Gents, I have an interesting problem I would like some ideas on for a solution. I cannot seem to find any code examples on the net, though I might not be looking in the right place really. I have some articles stored in a MySQL DB. What I want is if the article is above a certain length in characters, to page article through a few pages for site readability. So I would want to print X number of words/characters. Save the where the pointer is, move on to the next page, and display the same amount and so on for as many pages as needed. I know about pulling paged results using the limit function but that would not seem to apply as really I would want to page the results within one record (one field really). Does anyone have any ideas?? Thanks Phillip Ideas mentioned thus far are all good. At the end of 2005 we changed allnovascotia.com, a daily business digest, from continuous strip, to separate articles. Each article is stored in a database; the retrieved text is delivered via Flash. Presentation consists of headlines on left, story on the right in an htmlText control; clicking a headline loads the story into the htmlText control. Subscribers like the new format because the whole issue was getting rather long, and now they can gun down the headlines and quickly read the lead paras and decide whether or not they want more of that story. However - why do you think paging an article improves readability? What it does do is control the amount of text you display on a page so you can profitably surround it with advertising. It has no effect on readabilty -- that depends on the quality of the writing, clarity and size of font, and line length. So, give them good dynamic design, a legible font, the ability to resize the type and ensure that the pieces are well-edited and written for easy reading in a browser. Guess I'm an iconoclast, but when I see an artificially paged article I look for the Print View link so I can read it all at once. Heresy! Maybe that's another reason for paging -- you get more hits on the site. Guess this has been more like a semi-rant, and probably not helpful. g Cheers - Miles -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.385 / Virus Database: 268.5.2/329 - Release Date: 5/2/2006 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Paged Results Set in MySQL DB with one result
Phillip S. Baker wrote: Greetings Gents, I have an interesting problem I would like some ideas on for a solution. I cannot seem to find any code examples on the net, though I might not be looking in the right place really. I have some articles stored in a MySQL DB. What I want is if the article is above a certain length in characters, to page article through a few pages for site readability. So I would want to print X number of words/characters. Save the where the pointer is, move on to the next page, and display the same amount and so on for as many pages as needed. I know about pulling paged results using the limit function but that would not seem to apply as really I would want to page the results within one record (one field really). Does anyone have any ideas?? Apart from the other suggestions, you could modify your design a little bit. Instead of just having an articles table, you have an articles table and an article_pages table. Each page of your article is stored separately in the database and you don't have to do anything fancy to do your paging. create table articles( articleid int primary key, subject varchar(255), introduction text -- maybe? maybe not ); create table article_pages ( pageid int primary key, articleid int, -- points to the articles table content text, sortorder int ); simple join between the tables to get what you need.. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php