dongzouqie4220 2010-09-28 14:31
浏览 73
已采纳

如何使用PHP在URL中传递变量?

I have a variable called $tags, which just references from a database field. When the user clicks a link with the given $tags output in it, I want that data to be stored in a variable on the target page.

For instance, the user is on a todolist.php, that contains several tasks. They can see the parts associated with this task by clicking a link that goes to a partslist.php page. In the link, I need to contains the $tags data, so javascript on the partslist.php page knows what part to highlight.

So I need to know 1) how do I output $tags in the link of todolist.php, and 2) how do I receive that output and store it on a variable on the partslist.php page?

I have done similar POST and GET commands, but I can't quite figure this out.

  • 写回答

4条回答 默认 最新

  • drdawt9210 2010-09-28 14:34
    关注

    partslist.php?tags=<?php echo urlencode($tags) ?> .. is this what you are asking ? Or there are multiple tags ? Please give examples / code blocks / links

    On the partslists side you can do this :

    $tags  = $_GET['tags']; // You don't need urldecode here, because $_GET is a supergobal and it is already decoded. 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码