Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    breaking up data when displaying on web page [ was Is This Possible? ]

    I have a database with one table which includes all the data I need to display on my site. I want to display that data in multiple tables with spaces (a space where html can be added ) in between say every 10 data entries on my site. So I will have say a table displaying the first up to the 10th data entry in my database then a break for ads then continuing to the 11th to 20th data entry then a break for ads etc etc...I want to display say 5 tables of data per page (so 50 data entries, 10 per table, per page). I also need to add pagination because I will have around 300 data entries and need to break it up 50 per page (again 5 tables per page, 10 data entries per table, with spaces between tables where html can be placed) until the last table on the last page displays the last 10 data entries. All of this data will be updated often and changing however the number of data entries will not (say 300 all together). Any help will be much much appreciated, I am very desperate for a solution..Thank you!
    Last edited by guelphdad; 08-03-2006 at 01:12 PM. Reason: insufficient thread title

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    welcome here!

    I want to display that data in multiple tables with spaces (a space where html can be added ) in between say every 10 data entries on my site
    that's easy in most server side languaes. if you will be using php, then you can use the modulus for that. like
    PHP Code:
    $i 1
    while($row mysql_fetch_assoc($result)){
       if ((
    $i 10) == '0'){
          echo 
    '<br />';
       }
       
    // display row

    for the pagination --> run a google or search on the php forum. a few million read made examplecodes and tutorials should pop up.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #3
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,100
    Thanks
    2
    Thanked 23 Times in 23 Posts
    Just one small correction, raf. This line:

    Code:
    if (($i % 10) == '0'){
    should lose the quotes around the zero.

    Code:
    if (($i % 10) == 0){
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by vinyl-junkie
    Just one small correction, raf. This line:

    Code:
    if (($i % 10) == '0'){
    should lose the quotes around the zero.

    Code:
    if (($i % 10) == 0){
    no, it doesn't need correcting. try it out:
    PHP Code:
    $i 10;
    if (
    $i 10) == '0'){
        echo 
    '<br />quotes around the 0 are OK';
    }
    if (
    $i 10) == 0){
        echo 
    '<br />no quotes around the 0 is OK';

    will print:
    quotes around the 0 are OK
    no quotes around the 0 is OK

    i think you are confusing == with === because
    == '0' evaluates the same as == 0 whereas
    === '0' does not evaluate the same as === 0
    if ($i % 10) === '0'){ would be incorrect

    and besides, that code is just typed in quickly without rereading. so there are enough things wrong with it
    PHP Code:
    $i 
    should be
    PHP Code:
    $i 
    and inside the while loop, i should increment $i so you'll need to add
    PHP Code:
    $i ++; 
    maybe i should include a disclaimer: all code is typed in haste without being reread, lett alone debugged
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html


  •  

    Posting Permissions

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