Php 如何将结果数据作为超链接而不是普通数据进行回显?

Php 如何将结果数据作为超链接而不是普通数据进行回显?,php,mysql,Php,Mysql,我正在从Mysql数据库获取数据。 在代码的底部,返回的数据实际上是图像的网站链接。 如何使其显示为超链接而不是纯文本? 非常感谢您的建议。试试这个: 在这里,我将链接作为超链接的来源,以便它指向提供的链接。试试这个 <head> <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" href="

我正在从Mysql数据库获取数据。 在代码的底部,返回的数据实际上是图像的网站链接。
如何使其显示为超链接而不是纯文本? 非常感谢您的建议。

试试这个:

在这里,我将链接作为超链接的来源,以便它指向提供的链接。

试试这个

<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>

尝试以下操作:

        <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>


值得一看,这是一个很好的起点:)

这是HTML 101的东西。@Fred ii-,非常同意!死一般的HTML,我想是RTM的一个例子…@SamSwift呻吟,我从20多年前学到的东西。这是一项古老的技术,不管他们信不信,它至今仍然有效;-)@弗雷德二世-,对我来说不太长,你几乎在我老的时候就学会了;P只做了几年,知道这是基本的!但是说到这里,每个人都需要一个向他人学习的地方,并提出这样的问题:D“我怎样才能使它显示为超链接而不是纯文本?”谢谢@JamieSterling。Edited@AshishChoudhary谢谢你。这对我很有用。你知道如何调整img src的大小吗?谢谢。我很高兴这有帮助。如果有帮助,你可以选择它作为答案。图像大小可以使用
宽度
高度
属性进行调整。@William1234和AshlishChoudhary,我在我的答案中添加了链接和示例来帮助解决这个问题,我有指向w3schools的链接,请告诉我它是否有用:)锚定标记不能有“/>您缺少一个关键元素,即超链接文本;P我想你的意思是“3”;-)坏网址。啊,。。。好了。@Fred ii-我不能输入“ait!”!哈哈,你不就这么做吗?;-)@Wel121234,乐意帮助,如果解决了你的问题,请考虑正确的标记:
<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>