从mysql数据库显示图像

时间:2013-12-17 16:12:20

标签: mysql image

我修改了一个脚本,以显示来自2个MySQL表(玩家和图库)的信息。我想展示大尺寸的第一幅图像,以及主画面下方的小尺寸图像。

请参阅以下代码:

<html>
<head>
<title>Show photo gallery</title>
<style type="text/css">
*{margin:0px;padding:0px;-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;}
header{
    width:800px;
    height:80px;
    background:#ff5;
    padding:20px;
    }


.scroll {
   width: 200px;
   height: 400px;
    background: red;
   overflow: scroll;
}
.scroll::-webkit-scrollbar {
    width: 12px;
}

.scroll::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); 
    border-radius: 10px;
}

.scroll::-webkit-scrollbar-thumb {
    border-radius: 10px;
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); 
}

#carousel{background:#eee; height:500px; width:180px;overflow:auto;float:left;}

.desc{background:#ee9;padding:40px;height:60px;width:180px;float:left;margin:0px 15px;}
</style>
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/lightbox-2.6.min.js"></script>
<link href="css/lightbox.css" rel="stylesheet" />
</head><body>
<header><a href="view.php">Admin</a></header>
<br>
    <?
echo "<div id='carousel' class='scroll'>";

        mysql_connect("localhost","root","") or die(mysql_error());
        mysql_select_db("soccer");
        $strSQL = ("SELECT * FROM gallery WHERE player_id = $_GET[id]");
        $objQuery = mysql_query($strSQL);
        $Num_Rows = mysql_num_rows($objQuery);

        $Per_Page = 10;   // Per Page

        $Page = $_GET["Page"];
        if(!$_GET["Page"])
        {
            $Page=1;
        }

        $Prev_Page = $Page-1;
        $Next_Page = $Page+1;

        $Page_Start = (($Per_Page*$Page)-$Per_Page);
        if($Num_Rows<=$Per_Page)
        {
            $Num_Pages =1;
        }
        else if(($Num_Rows % $Per_Page)==0)
        {
            $Num_Pages =($Num_Rows/$Per_Page) ;
        }
        else
        {
            $Num_Pages =($Num_Rows/$Per_Page)+1;
            $Num_Pages = (int)$Num_Pages;
        }

        $strSQL .=" order  by GalleryID ASC LIMIT $Page_Start , $Per_Page";
        $objQuery  = mysql_query($strSQL);


    //  echo"<table border=\"0\"  cellspacing=\"1\" cellpadding=\"1\"><tr>";
        $intRows = 0;
        while($objResult = mysql_fetch_array($objQuery))
        {
    //  echo "<td>"; 
            $intRows++;
    ?>
        <div class="img">
<a class="example-image-link" href="uploads/<?=$objResult["Picture"];?>" data-lightbox="example-1"><img class="example-image" src="uploads/<?=$objResult["Picture"];?>" alt="thumb-1" width="160"></a>
</div>
                <br>
    <?
            echo"</td>";
            if(($intRows)%2==0)
            {
                echo"</tr>";
            }
        }
        echo"</tr></table>";
    ?>

        <br>
        Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :
        <?
        if($Prev_Page)
        {
            echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
        }

        for($i=1; $i<=$Num_Pages; $i++){
            if($i != $Page)
            {
                echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
            }
            else
            {
                echo "<b> $i </b> <br/><br/>";
            }
        }
        if($Page!=$Num_Pages)
        {
            echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a><br/><br/> ";
        }
echo "</div>";

            ?>

            <?php   
            echo '<div class="desc">';
$query = "SELECT * FROM players WHERE id = $_GET[id]";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['firstname']."\n\n";
echo $row['lastname'];
        } 
echo "</div>";
                ?>
        </body>
</html>
<?
mysql_close();
?>       

0 个答案:

没有答案