How do I echo a variable inside the tag? this code does not seem to work. Any help is appreciated.
echo "<a href='productdetails.php?image="$results['image']"'><img src='images/".$results["image"]."' class='img-responsive' /></a><br />";
答案 0 :(得分:4)
喜欢这个
echo "<a href='productdetails.php?image="{$results['image']}"'>
<img src='images/{$results["image"]}' class='img-responsive' />
</a><br />";
或
echo "<a href='productdetails.php?image="$results[image]"'>
<img src='images/$results[image]' class='img-responsive' />
</a><br />";
或者喜欢你的原作,但使用正确的连接
echo "<a href='productdetails.php?image=" . $results['image'] . "'>
<img src='images/".$results["image"]."' class='img-responsive' />
</a><br />";
答案 1 :(得分:2)
应该是这样的,你在.
之前和之后错过了$results['image']
,所以没有发生正确的连接:
echo "<a href='productdetails.php?image=" . $results['image'] . "'><img src='images/" . $results["image"] . "' class='img-responsive' /></a><br />";
方法2: 把它放在变量中:
$image = $results['image'];
echo "<a href='productdetails.php?image=" . $image . "'><img src='images/" . $image . "' class='img-responsive' /></a><br />";
答案 2 :(得分:0)
或者像这样:
echo
'<a href="productdetails.php?image=' . $results['image'] . '">
<img src="images/' . $results['image'] . '" class="img-responsive" />
</a><br />';