用php制作简单的图库

时间:2015-04-15 15:26:19

标签: php mysql html-table image-gallery

此代码有效,但点击它时不会以实际尺寸打开图片。

echo "<table>";
$res = "SELECT * FROM table1";
$result = $mysqli->query($res);
    while($myRow = $result->fetch_array())
    {   
        echo "<tr>";
        echo "<td>"; ?><a href='./display_images2.php?showrealsize'> <img src="<?php echo $myRow["image"];  ?>" height="100" width="100"> </a> <?php echo "</td>"; 
        echo "<td>"; echo $myRow["name"]; echo "</td>";
        echo "</tr>";
    }

    if(isset($_GET['showrealsize'])){
    echo $_GET[$myRow["image"]];
    }

1 个答案:

答案 0 :(得分:0)

在这种情况下,您需要将您的网址showrealsize设置为$myRow["image"]if(isset($_GET['showrealsize'])), then you can either simply echo $ _GET [&#39; showrealsize&#39;]`,或者执行我在下面执行的操作并回显图像中的src链接。

 echo "<table>";
    $res = "SELECT * FROM table1";
    $result = $mysqli->query($res);
        while($myRow = $result->fetch_array())
        {   
            echo "<tr>";
            echo "<td>"; ?><a href="./display_images2.php?showrealsize=<?php echo $myRow['name']"> <img src="<?php echo $myRow["image"];  ?>" height="100" width="100"> </a> <?php echo "</td>"; 
            echo "<td>"; echo $myRow["name"]; echo "</td>";
            echo "</tr>";
        }

        if(isset($_GET['showrealsize'])){
        echo "<img src="<?php echo $_GET['showrealsize'];  ?>" height="100" width="100">";
        }