Jahed Hussain
Jahed Hussain

Reputation: 183

Pass Variable Through An Image Hyperlink?

how do i hyperlink an image and also pass a variable through it as well? my incorrect code is as follows:

    <?php
            $result=mysql_query("select serial, name, price from products ORDER BY RAND() LIMIT 3");
            while($row=mysql_fetch_array($result))
            {
                echo '<a href="searchedproduct.php?product_id=<?=$row['serial']?>"><img src="getImage.php?id=' . $row['serial'] .'"/></a>'.'&nbsp;'.'&nbsp;';
}

echo "</tr>";
echo "</table>";
?>

thanks for any help guys

Upvotes: 0

Views: 303

Answers (1)

Rufinus
Rufinus

Reputation: 30741

as Book of Zeus said, you have a syntax error:

<?php
$result=mysql_query("select serial, name, price from products ORDER BY RAND() LIMIT 3");
    while($row=mysql_fetch_array($result))
    {
        echo '<a href="searchedproduct.php?product_id='.$row['serial'].'"><img src="getImage.php?id=' . $row['serial'] .'"/></a>'.'&nbsp;'.'&nbsp;';
    }

echo "</tr>";
echo "</table>";
?>

Upvotes: 2

Related Questions