RE: loop structure(SOLVED)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thx, it works like a charm
I think the mysql_fetch_assoc was the thing I was looking for.

-----Oorspronkelijk bericht-----
Van: Robert Cummings [mailto:robert@xxxxxxxxxxxxx] 
Verzonden: zaterdag 9 september 2006 17:36
Aan: rv@xxxxxxxx
CC: php-general@xxxxxxxxxxxxx
Onderwerp: Re:  loop structure


Untested... ... ...

<?php

if( ($result = mysql_query( $query )) === false )
{
    // do something other than die you lazy ass programmers.
}
else
{
    $hits = mysql_num_rows( $result );
    $cols = 3;
    $rows = ceil( $hits / $cols );

    for( $i = 0; $i < $rows; $i++ )
    {
        for( $j = 0; $j < $cols; $j++ )
        {
            $picture = '';
            if( ($item = mysql_fetch_assoc( $result )) !== false )
            {
                echo '<td width="120" valign="top">'
                    .$item['picture']
                    .'</td>'
                    .'<td width="13" valign="top">'
                    .'<!--DWLayoutEmptyCell-->&nbsp;'
                    .'</td>';
            }
        }
    }
}

?>

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux