Justtechjobs.com Find a programming school near you






Online Campus Both


php-general | 2001122

[PHP] 3 column by n rows table From: Rodrigo Peres (rperes <email protected>)
Date: 12/26/01

Hi list,

I have a script that grab data from mysql and generate a table order by name
and with images at the beggining of each new letter, something like a index.
My problem is that I need to buil a table with 3 column by n row. The
problem of creating the <tr> etc is ok! But I can't figure out how to stop
the table and initiate another <tr> if the letters change, someone can
help?? Here is my code that generate the letters and Index for them:

$ultletra = '';
$row = '';
while($resultado = $query->dados()) {
    $curletra = $resultado['letra'];
    if($curletra != $ultletra) {
            $row .= "<tr>\n<td>\n<img src=\"img/letras/$curletra.gif\"
width=\"24\" height=\"24\">\n</td>\n</tr>\n";
    }
    $row .= "<td><a
href=\"interna.php?cat=$resultado[Nome_Categoria]&celebID=$resultado[CelebID
]\">".$resultado['Nome_Artistico']."</a></td>\n";
    $ultletra = $curletra;

}

and the sql command is:

SELECT
categorias.Nome_Categoria,celebridades.CelebID,celebridades.Nome_Artistico,
lcase(left(Nome_Artistico,1)) as letra FROM categorias LEFT JOIN
celebridades ON categorias.CategoriaID=celebridades.Categoria WHERE
CategoriaID='1' ORDER BY Nome_Artistico

Thank's in advance

Rodrigo Peres

-- 

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>