dsfhe34889 2015-11-02 08:30
浏览 49
已采纳

通过URL在页面中传递变量

Here are two codes one works fine while other doesn't can anyone explain me what is wrong with second code.

$Id = $row['id'];
<a href="page2.php?Id=<?php echo $row['id'] ?>">Product></a>

The code above works fine. But the code below doesn't. On page two I am using get method.

<a href="page2.php?Id=$Id">Product></a>
  • 写回答

3条回答 默认 最新

  • doutui7955 2015-11-02 08:34
    关注

    You not print php variable without echo or php tag

    <a href="page2.php?Id=<?php echo $Id; ?>">Product></a>
    

    So change this :-

    href="page2.php?Id=$Id"
    

    to this :-

    href="page2.php?Id=<?php echo $Id; ?>"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?