Jump to content

[SOLVED] Limiting/Structuring Query Data Output


halifaxer

Recommended Posts

Have had a browse around already and can't find any topics related to this, so I'll give it a go here.

 

Let's say I have a table called "customers" which will display many many results.

 

What I want to be able to do is output their names in a structured table when a query is presented.

 

For example:

 

Customer 1, Customer 2, Customer 3, Customer 4

Customer 5, Customer 6, Customer 7, Customer 8

 

... where it will always revert to the next row after every 4 results, continuing as such.

 

Can anyone help me? I imagine it's quite a simple code but I'm hopeless :)

Link to comment
Share on other sites

There was a topic about this a while ago (maybe 2 months) which covered it pretty extensive... try to look again, maybe it's called something like "dynamic tables" :)

 

Else have a look here:

 

http://www.phpbuilder.com/columns/patterson20050620_5.php3

 

or here:

 

http://www.weberdev.com/get_example-3994.html

 

They cover the subject too :)

Link to comment
Share on other sites

Something like this will make a new row in a table every 4 columns.

 

echo "<table><tr>"
$i=0;
while ($row = mysql_fetch_array($qry))
{
    if ($i >3)
    {
        echo "<tr>";
        $i=0;
    }
    echo "<td>$row['field']";
    $i++;
}

Link to comment
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.