2011-11-08 54 views
0

我使用表格從我的數據庫中獲取汽車信息,並且此表中的每列包含汽車信息,但是在最後一列中我想查看其中的汽車圖片,保存在我的數據庫中,我已經擁有我的代碼從我的數據庫中獲取圖片,並可直接在瀏覽器中查看它。但我如何直接在表格列中查看圖片而無需在新窗口中打開圖片。 視圖代碼查看錶中提取的圖片

while($rows=mysql_fetch_array($result)){ 
?> 
<tr> 
<td class="style1"><?php echo $rows['branch']; ?></td> 
<td class="style1"><?php echo $rows['model']; ?></td> 
<td class="style1"><?php echo $rows['doors']; ?></td> 
<td class="style1"><?php echo $rows['fuel']; ?></td> 
<td class="style1"><?php echo $rows['engine']; ?></td> 
<td class="style1"><?php echo $rows['colo']; ?></td> 
<td class="style1"><?php echo $rows['wheel']; ?></td> 
<td class="style1"><?php echo $rows['condit']; ?></td> 
<td class="style1"><?php echo $rows['warranty']; ?></td> 
<td class="style1" style="width: 47px"><?php echo $rows['price']; ?></td> 
<td class="style1"><?php echo $rows['CarOwner']; ?></td> 
<td align="center" class="style3"><a href="info.php?id=<?php echo $rows['CarOwner']; ?>"><?php echo $rows['CarOwner']; ?></a></td> 
<td align="center" class="style3"><?php echo "download.php"; ?></td> 

,並從MySQL

此下載圖像
<?php 
//$id = $_GET['id']; 
include_once 'D_B.php';// Connect to server and select database. 
$query = "SELECT `name`, `type`, `size`, `content` FROM `upload` WHERE `id`='1'"; 
$result = mysql_query($query) or die('Error, query failed'); 
list($name, $type, $size, $content) =mysql_fetch_array($result); 

header("Content-length: $size"); 
header("Content-type: $type"); 
echo $content; 
exit; 
?> 
+1

你不知道圖像的HTML標籤? –

回答

0

只要用你的鏈接地址爲<img>標籤src屬性,像這樣:

<td><img src="image.php?id=<?php echo $rows['imageId']; ?>"/></td>