Jump to content

Recommended Posts

Hi guys.

I have trawled countless forums and tutorials on various websites Devnetwork, phpbuilder etc and I can't really seem to find an answer to my problem. Maybe they just haven't been explained in a way I understand yet. :/

I have already paginated my results pulled from MySQL database... it was easy I copied the tutorial in the book (I'm sure there is a better way of writing it but I'll go back and look at that when I'm a bit more proficient).

I am pulling records from MySQL database which are articles with some images included. The articles are of various lengths and the images various sizes. As the result of this limiting to 5 records per page has different results depending on which articles are to be displayed.

Page 1 currently has a lot of space at the bottom of the page as the articles displayed here are quite short. Page 2 has large articles and overshoots the bottom of my page template causing the /div its posted in to continue on past the bottom of the rest of my page.

Is there a way of limiting results based on total number of characters contained in a specific field (if I establish how many characters could fit on the page to begin with)instead of just limiting by number of rows returned?

Or is it possible to create (from the query results) a page height variable that can be posted to the other parts of my web page so that the rest of the site fits the results.

If either is possible which would be the better of the two? If not any suggestions with how to deal with this? Any links to resources which might give me ideas on where to start with the coding would also be appreciated.

Thanks
Link to comment
https://forums.phpfreaks.com/topic/5029-pagination/
Share on other sites

You could count the number of characters in a post and use some clauses, but I have another thought..

When you insert the articles into the database, perhaps you could classify them as LONG, MED, SHORT, then use some logic like LONG=2*MED and MED=2*SHORT, so you post 1 LONG or 2 MED or 4 SHORT or 1 MED and 2 SHORT, etc...

Now it's just building the logic in your querries...
Link to comment
https://forums.phpfreaks.com/topic/5029-pagination/#findComment-17814
Share on other sites

You can trim the length of the text returned by using the php function substr(). I would howerver suggest that you fit the way your html works to allow any size text to be placed in your div without stretching out of the rest of the page.

Your css should not allow a div insidea containing div to outsize the container. (i.e the container should enlarge first, allowing the inside div to also expand, allowing the full text to be placed into it.)
Link to comment
https://forums.phpfreaks.com/topic/5029-pagination/#findComment-17815
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.