Jump to content

Recommended Posts

I tried searching for this before posting, but I'm not even sure what to search for. Obviously I couldn't find what I was looking for, so hopefully it isn't too stupid a question (I am very noob with PHP still).

 

I have a lot of data that I am pulling from a MySQL DB and displaying it in a crude table. Is there anyway to start the while loop (pulling up say, 80 results), and direct it to print a row of headings every 20 results? So that way the users still know what they are looking at even when scrolled down to the bottom.

 

Or is this the wrong question to ask? ;)

 

Thanks for any help!

Shane

You can do it 2 ways.  Either limit the sql query to 20 results and have multiple queries, or have some sort of counter that increases each time the loop is executed.  When it gets to 20 (or a multiple thereof), include the headings.

 

<?php
$i = 0;
while($array = mysql_fetch_array($query))
{
    if(fmod($i,20) == 0)
    {
        //echo heading
    }
    //echo current line
}
?>

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.