通过图像超链接传递变量?

时间:2011-12-17 00:00:28

标签: php

我如何超链接图像并通过它传递变量?我的错误代码如下:

    <?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>";
?>

感谢任何帮助人员

1 个答案:

答案 0 :(得分:2)

正如宙斯之书所说,你有一个语法错误:

<?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>";
?>