如何在新窗口中打开数据库中显示的图片
How to open a pictute displayed from the DB in a new window?
我有一个页面显示了几张图片。每个图像路径都存储在数据库中,这就是我使用php显示它们(从它们的路径)的方式。
我如何才能让用户点击图片时,它会在新窗口或弹出窗口中打开?我看了很多东西,但没有显示如何对数据库中的输出进行处理。这是我的代码:
<!DOCTYPE HTML>
<html>
<body>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="jquery.imagemapster.js"></script>
<link rel="stylesheet" type="text/css" href="css.css" />
<title>VisitBulgaria</title>
</head>
<div class="banner">
<a href="home.html">
<img src="images/banner.png" alt="home" border="0" height="150" width="500" /></a>
<div class="namelog">
<?php
if (isset($_SESSION['ID'])){
echo $Forename." ".$LastName;
echo '<a href="logout.php">Logout</a> / ';
echo '<a href="userpage.html">Account</a>';
}
else {
if (!isset($_SESSION['ID'])){
echo '<a href="login.php">Log In</a> / ';
echo '<a href="register.php">Register</a>';
}
}
?>
</div>
<div class="center11">
<div class="attractions2">
<?php
if (!$link = mysql_connect()) {
echo 'Could not connect to mysql';
exit;
}
if (!mysql_select_db('visitbulgaria', $link)) {
echo 'Could not select database';
exit;
}
$villageId = $_GET['village'];
$sql = "SELECT `AttractionID`, `Name`, `Location`, `Description`, `Airport`, `imglink`,`imglink2`,`imglink3`,`imglink4`,`imglink5` FROM `attractions` WHERE `AttractionID`='$villageId'";
$result = mysql_query($sql, $link);
if (!$result) {
echo "DB Error, could not query the database'n";
echo 'MySQL Error: ' . mysql_error();
exit;
}
while ($row = mysql_fetch_assoc($result)) {
echo $row['Name'];
echo "<br />" ;
echo " Location: ".$row['Location'] ." ";
echo "<br />" ;
echo $row['Description'];
echo "<br />" ;
echo " Nearest Airport: ".$row['Airport'] ." ";
echo "<br />" ;
echo "<br />";
echo '<img src="'.$row['imglink'].' " height="200" width="500">';
echo "<br />";
echo '<img src="'.$row['imglink2'].' " height="250" width="250">';
echo " ";
echo '<img src="'.$row['imglink3'].' " height="250" width="250">';
echo "<br />";
echo '<img src="'.$row['imglink4'].' " height="250" width="250">';
echo " ";
echo '<img src="'.$row['imglink5'].' " height="250" width="250">';
echo "<a href='favourite.php?village=" . $row['AttractionID'] . " '>" .
"<img src='img/fav.png' >
</a>";
}
mysql_free_result($result);
?>
</body>
</html>
将target="_blank"添加到每个img href,例如
echo '<a href="'.$row['imglink'].'" target="_blank"><img src="'.$row['imglink'].' " height="200" width="500"></a>';
相关文章:
- 防止Iframe窗体在新窗口中打开
- 如何在新选项卡中而不是在新窗口中打开URL
- 为在新窗口中打开外部链接创建异常
- SVG编辑链接获胜't在新窗口中打开
- 如何将数据传递给 jsp 并从 servlet 在新窗口中打开它
- 将坐标传递到HTML页面以在新窗口中打开谷歌街景
- ASP.Net电子邮件有一个超链接应该在新窗口中打开
- 如何在新窗口中打开url
- 在新窗口中打开时,未在画布中绘制图像
- 如何在新窗口中打开打印
- 使用javascript在新窗口中打开重定向操作
- AngularJS-使用ng-click在新窗口中打开链接
- 在新窗口中打开DIV按钮
- 无法在新窗口中打开 javascript 搜索引擎结果
- 使用javascript在新窗口中打开链接
- 在新窗口中打开链接
- 在新窗口中打开 .但标准是_blank
- IE10 单击缩略图会在新窗口中打开大图像,而不是替换特色图像
- 在新窗口中打开链接,然后立即显示打印窗口
- 如何在新窗口中打开数据库中显示的图片