开发者

Using PHP, within a search, how do I contain an html link in an image from my MySql database?

This is my problem: I have an ecommerce website, and I would like my search results to come up with products that have their links avaiable either wit开发者_如何学运维hin the image of the product on the search page, or next to the image. My current code looks like this:

if($_GET['searchBox'] !='')
{
    if(mysql_num_rows($searchresult)==0) {
        echo 'Your search returned no results';
    }
    else 
    {
        while ($row = mysql_fetch_assoc($searchresult))]
        {
           echo "<img src='".$row['image']."'/>".'   '.$row['name'].'   £'.$row['price'].'    '.$row['ProductUrl'];
        }
    }
}

?> 

I have spent ages trying to get an URL into the image area, but I can't make it work.

Please help!!


What the problem put image in to the anchor tag.

Have you tried like this

 echo "<a href='".$row['ProductUrl']."'><img src='".$row['image']."'/></a>";

EDIT

 echo "<img src='".$row['image']."'/>".'   '.$row['name'].'   £'.$row['price'].'
        <a href="'.$row['ProductUrl']."'>".$row['ProductUrl']."</a>";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜