Rodrigo,

Nice looking page. I'm not going to try and fix your logic, because you've approached 
it somewhat 
differently than I would. Here's my logic or pseudocode ...

Set max_columns to 3
Set a letter variable
While I have results
   While column_count is less than max_columns or letter is the same as old_letter
      Create a cell, fill it with data, echo it to screen
      Increment the column counter
      Set old_letter to this letter
   Otherwise
      Close the row, echo it
      Start a new row, echo it
      Reset column counter
      Set a letter variable

That's roughly it. I've skipped putting in the cell for the letter graphic, you may 
want to do that in the Otherwise block. I've also skipped creation of the initial row, 
which 
would be done outside the while loop.

I know this can be improved upon to make it more robust, but let's hope it gets you 
to your goal.

Merry Christmas - Miles Thompson

On Thursday 27 December 2001 10:22 am, Rodrigo Peres wrote:
> Hi list,
>
> I am in a big trouble. My deadline is coming and I couldn't solve my
> problem yet! I have this script that outputs a table that can be seen at
> http://www.celebnet.com.br/abc.php
>
> $ultletra = '';
> $row = '';
> while($resultado = $query->dados()) {
>     $curletra = $resultado['letra'];
>     if($curletra != $ultletra) {
>         if (!empty($row)) {
>            $row .= "</tr>\n";
>         }
>             $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[CelebI
>D ]\">".$resultado['Nome_Artistico']."</a></td>\n";
>     $ultletra = $curletra;
> }
> if (!empty($row)) {
>    $row .= "<tr>\n";
> }
>
> SQL 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
>
> My problem is that I need to modify the script to output a 3 column table.
> I have tried everything but nothing works, and I've tried also all url
> about PHP that i could found. Please I'll appreciate any help.
>
> Thank's in advance and happy new year to all!!!
>
> Rodrigo Peres (Brazil)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to