如何在PHP中创建图像URL

时间:2017-01-25 19:45:06

标签: php html html5

我的SQL数据库上有一个图像,并显示为

<html>
<head>
<title>image show</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body>
<?php
    $objConnect = mysql_connect("localhost","root","") or die("Error Connect to Database");
    $objDB = mysql_select_db("images");
    $strSQL = "SELECT * FROM files";
    $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="340" border="1">
<tr>
<th width="50"> <div align="center">Files ID </div></th>
<th width="150"> <div align="center">Picture</div></th>
<th width="150"> <div align="center">Name</div></th>
<th width="150"> <div align="center">Edit</div></th>
</tr>
<?php
    while($objResult = mysql_fetch_array($objQuery))
    {
?>
<tr>
<td><div align="center"><?php echo $objResult["FilesID"];?></div></td>
<td><center><img src="ViewImage.php?FilesID=<?php echo $objResult["FilesID"];?>"></center></td>
<td><center><?php echo $objResult["Name"];?></center></td>

</tr>
<?php
    }
?>
</table>
<?php
mysql_close($objConnect);
?>
</body>
</html>

ViewImage.php

<?php
    $objConnect = mysql_connect("localhost","root","") or die("Error Connect to Database");
    $objDB = mysql_select_db("images");
    $strSQL = "SELECT * FROM files WHERE FilesID = '".$_GET["FilesID"]."' ";
    $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
    $objResult = mysql_fetch_array($objQuery);

    echo $objResult["FilesName"];?>

现在显示网址“http://localhost/image_upload/ViewImage.php?FilesID=1” ,但我想点击我的图片并显示“http://localhost/image_upload/ViewImage/something.jpg

等网址

谢谢

0 个答案:

没有答案