<?
    $GLOBALS
['highlight'] = 'tiles_completed';

    require_once(
'include/functions/pages.php');

    include(
'include/parts/header.php');

    
$entries mysql_fetch_array(mysql_query("SELECT COUNT(*) AS num FROM tiles WHERE user_id = '" $GLOBALS['auth']['id'] . "' AND deleted = '0'"));
    
$page_count ceil($entries['num'] / 25);
    
$pages '<span class="pages">Page: ' pages('?s=tiles_completed'$_page$page_count) . '</span><br />';
?>

<div class="header">Completed Tiles<?= $entries['num'] ? '<br />' $pages '' ?></div>

<div class="content" style="padding: 0px 5px 5px 5px;">
<?
    $tiles 
mysql_query("SELECT * FROM tiles WHERE user_id = '" $GLOBALS['auth']['id'] . "' AND deleted = '0' ORDER BY tile_id DESC LIMIT " . (($_page 1) * 25) . ', ' 25);
    if (
mysql_num_rows($tiles))
    {
        echo 
'<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td>';
        while (
$tiles_row mysql_fetch_array($tiles))
        {
             
$quilts mysql_query("SELECT * FROM quilts WHERE id = '" $tiles_row['quilt_id'] . "'");
            if (
$quilts_row mysql_fetch_array($quilts))
            {
                if (
$quilts_row['tile_width'] > 100)
                {
                    
$new_width 100;
                    
$new_height $quilts_row['tile_height'] / ($quilts_row['tile_width'] / 100);
                    if (
$new_height 100)
                    {
                        
$new_width $quilts_row['tile_width'] / ($quilts_row['tile_height'] / 100);
                        
$new_height 100;
                    }
                }
                elseif (
$quilts_row['tile_height'] > 100)
                {
                    
$new_height 100;
                    
$new_width $quilts_row['tile_width'] / ($quilts_row['tile_height'] / 100);
                    if (
$new_height 100)
                    {
                        
$new_height $quilts_row['tile_height'] / ($quilts_row['tile_width'] / 100);
                        
$new_width 100;
                    }
                }
                else
                {
                    
$new_width $quilts_row['tile_width'];
                    
$new_height $quilts_row['tile_height'];
                }
                echo 
'<div style="width: 100px; height: 100px; margin: 4px 4px 0px 0px; padding: 4px; border: solid 2px black; float: left;">';
                echo 
'<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td>';
                echo 
'<a href="?s=tile&i=' $tiles_row['tile_id'] . '"><img src="?g=tile&i=' $tiles_row['tile_id'] . '" width="' $new_width '" height="' $new_height '" title="' htmlspecialchars(get_username($tiles_row['user_id'])) . ': ' htmlspecialchars($tiles_row['comment']) . '" alt="" style="border: solid 0px black;"></a><br />';
                echo 
'</td></tr></table>';
                echo 
'</div>';
            }
        }
        echo 
'</td></tr></table>';
    }
    else
    {
        echo 
'<div style="padding: 5px 0px 0px 0px;"></div>You do not have any tiles completed.';
    }
?>
</div>

<?
    
if ($entries['num'])
    {
        echo 
'<div class="header">' $pages '</div>';
    }

    include(
'include/parts/footer.php');
?>