<?php

    $consulta = "SELECT * FROM postres;";
    $resultado = mysql_query($consulta) or die(mysql_error());

    if (mysql_num_rows($resultado) > 0)
    {
        echo '<center><table width="' . ($body_width-80) . '" border="1" cellpadding="10" cellspacing="0" class="cuerpo">';
        $columnas = 0;
        $hay_fila_llena = FALSE;
        while ($row = mysql_fetch_assoc($resultado))
        {
            if ($columnas == 0) { echo "<tr>"; }
            echo '<td align="center" valign="middle" class="cuerpo"><center>';
            if (file_exists("img/postres/" . $row["id"] . ".gif")) { echo '<img src="img/postres/' . $row["id"] . '.gif"><br>'; }
            else if (file_exists("img/postres/" . $row["id"] . ".jpg")) { echo '<img src="img/postres/' . $row["id"] . '.jpg"><br>'; }
            echo '<font size="3" color="#000000" face="courier">'. $row[$idioma_usado] . '</font><br>';
            echo '</center></td>';
            $columnas++;
            if ($columnas == 3) { echo "</tr>"; $columnas = 0; $hay_fila_llena = TRUE; }
        }
        if ($columnas < 3 && $columnas != 0 && !$hay_fila_llena) { echo "</tr>"; }
        else if ($columnas < 3 && $columnas != 0)
        {
            while ($columnas < 3 && $columnas != 0) { echo '<td class="cuerpo"><img src="img/blank.gif" width="1" height="1" border="0" hspace="0" vspace="0"></td>'; $columnas++; if ($columnas == 3) { echo "</tr>"; } }
        }
        echo '</table></center>';
    }

?>
