dounai9294 2017-05-29 20:36
浏览 58
已采纳

根据单击的链接更改SQL查询

I'm redesigning a website, and have what I've found to be an interesting problem to solve.

On the original site, there is a list of links; and each link returns its own page that shows almost identical data to the other link pages. The only difference between each of these pages is the sql query that's run upon clicking the link. As a result, there are many redundant pages that, in my mind, could be solved with one smarter page.

I want to have one smarter global page that all the links go to, but want that smart page to be able to know which link was clicked to get there, and will run a different query based on the link it's coming from.

Is there a good/clean way to do this? I am excited by the thought, but am having trouble with implementation.

Thanks in advance for the help!

  • 写回答

2条回答 默认 最新

  • duanlijia5864 2017-05-29 20:54
    关注

    You can do this by making one PHP file that always checks for a GET query string parameter and display content based on the parameter. The link would be the same but the parameter at the end would be different.

    So like this:

    Http://www.thelink.com/the_file.php?content=content_1
    

    And then in the PHP file check if $_GET['content'] is set and not empty and have some default content or message if it isn't set as an error checker.

    You could do a switch check to display content if the data structure allows. Else you could do an if else if type of checks on the value of $_GET['content'].

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计