<head>
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css"
rel="stylesheet" type="text/css" href="css/search.css">
</head>
<?php
include("productconfig.php");
$sql = "";
$sql .= "SELECT * FROM weeklytbakl";
if (isset($_POST['search']))
{
$search_term = mysql_real_escape_string($_POST['searchbox']);
$sql .= " WHERE description LIKE '%$search_term%'";
}
$query = mysql_query($sql) or die(mysql_error());
?>
<h1 align="center"> Search Product </h1>
<div class="box">
<div class="container-4">
<form name="search_form" method="POST" action="search_data.php">
Search for product: <input type="text" name="searchbox" value="" />
<input type="submit" name="search" value="Search" class="icon">
</form></div> </div>
<p align="left"><a href="index.php"><img src="pic/home.png" onclick="AjaxResponse()" width="20" height="20" /></a></p>
<table border="2" cellpadding="5" cellspace="5">
<tr>
<td bgcolor="#CCCCCC" style="font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif"><strong>ID</strong></td>
<td bgcolor="#CCCCCC" style="font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif"><strong>Code</strong></td>
<td bgcolor="#CCCCCC" style="font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif"><strong>Image Link</strong></td>
<td bgcolor="#CCCCCC" style="font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif"><strong>Description</strong></td>
<td bgcolor="#CCCCCC" style="font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif"><strong>Instock</strong></td>
<td bgcolor="#CCCCCC" style="font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif"><strong>Week 1</strong></td>
<td bgcolor="#CCCCCC" style="font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif"><strong>Week 2</strong></td>
<td bgcolor="#CCCCCC" style="font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif"><strong>Week 3</strong></td>
<td bgcolor="#CCCCCC" style="font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif"><strong>Week 4</strong></td>
</tr>
<?php while ($row = mysql_fetch_array($query))
{ ?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['code']; ?></td>
<td><?php echo $row['image']; ?></td>
<td><?php echo $row['description']; ?></td>
<td><?php echo $row['instock']; ?></td>
<td><?php echo $row['week1']; ?></td>
<td><?php echo $row['week2']; ?></td>
<td><?php echo $row['week3']; ?></td>
<td><?php echo $row['week4']; ?></td>
</tr>
<?php }?>
</table>
我正在从我的Mysql数据库中获取数据。在代码的底部,里面回显的数据其实是一个网站链接的图片。如何使其显示为超链接而不是纯文本?非常感谢您的任何建议。
最好的
方法已经被Jamie Stirling提出了。
它是要做的:
<td>
<a href="<?=$row['image_or_uri'];?>">
<img src="<?=$row['image']?>" height="120" width="120" />
<!-- I made a whoopsie, you don't need to specify the 'px' in the tag as it does it for you :P -->
</a>
</td>
可能值得在这里和这里看看,从:)开始的好地方
试试这个:
<td><a href="<?php echo $row['image']; ?>">Hyperlink</a></td>
在这里,我将链接作为超链接的来源,以便它指向提供的链接。
试试这个
<td><a><?php echo $row['id']; ?></a></td>
<td><a><?php echo $row['code']; ?></a></td>
<td><a><?php echo $row['image']; ?></a></td>
<td><a><?php echo $row['description']; ?></a></td>
<td><a><?php echo $row['instock']; ?></a></td>
<td><a><?php echo $row['week1']; ?></a></td>
<td><a><?php echo $row['week2']; ?></a></td>
<td><a><?php echo $row['week3']; ?></a></td>
<td><a><?php echo $row['week4']; ?></a></td>
尝试如下:
<td><a href="<?php echo $row['image']; ?>">Link</a></td>