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 />";
Like this
echo "<a href='productdetails.php?image="{$results['image']}"'>
<img src='images/{$results["image"]}' class='img-responsive' />
</a><br />";
Or
echo "<a href='productdetails.php?image=$results[image]'>
<img src='images/$results[image]' class='img-responsive' />
</a><br />";
Or like your original but with the correct concatenation
echo "<a href='productdetails.php?image=" . $results['image'] . "'>
<img src='images/".$results["image"]."' class='img-responsive' />
</a><br />";
It should be like this, you missed .
before and after $results['image']
, so proper concatenation is not happening:
echo "<a href='productdetails.php?image=" . $results['image'] . "'><img src='images/" . $results["image"] . "' class='img-responsive' /></a><br />";
Method 2: Take it in a variable:
$image = $results['image'];
echo "<a href='productdetails.php?image=" . $image . "'><img src='images/" . $image . "' class='img-responsive' /></a><br />";
Or like this:
echo
'<a href="productdetails.php?image=' . $results['image'] . '">
<img src="images/' . $results['image'] . '" class="img-responsive" />
</a><br />';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.