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 :)

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 :)

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++;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.