简体   繁体   English

如何为网站上的每个产品设置不同的URL?

[英]How do I make a different URL for every product on my website?

So I'm working on an affiliate website and I'm trying to figure out how to get a different URL for every product on my website. 因此,我正在一个会员网站上工作,试图找出如何为我的网站上的每种产品获取不同的URL。

So let's say i've got a page called www.mywebsite.com/products with all the different products on there that I get from my database. 因此,假设我有一个名为www.mywebsite.com/products的页面,上面有从数据库中获得的所有不同产品。 When I click on one of the products it's supposed to go to the URL www.mywebsite.com/products/testproduct. 当我单击其中一种产品时,应该转到URL www.mywebsite.com/products/testproduct。 If I click on a different product it's supposed to go to www.mywebsite.com/products/testproduct 2 etc... How do I get a URL for every product on my product page? 如果我单击其他产品,则应该访问www.mywebsite.com/products/testproduct 2等。如何在产品页面上获取每个产品的URL? I've been searching for a long time and I'm sure it's an easy solution cause every webshop has this function, but I just can't really explain what I want to Google, so that's why I'm asking here. 我已经搜索了很长时间,并且我确信这是一个简单的解决方案,因为每个网店都具有此功能,但是我只是无法真正向Google解释我想要的东西,所以这就是为什么我在这里询问。

Is there like a term for this that I can look up? 我可以查询一下这个术语吗? Any help would be appreciated. 任何帮助,将不胜感激。

Thanks 谢谢

You could make the website with a GET element. 您可以使用GET元素创建网站。

So you list all your items on the page product/, and when you click on something it will link to testproduct/?id=[itemid] 因此,您在产品product /页面上列出了所有商品,当您单击某些内容时,它将链接到testproduct /?id = [itemid]

Then you can use php 然后您可以使用php

$_GET['id'];

and with that you can request all details from the database and print them on the page. 这样您就可以从数据库中请求所有详细信息,并将其打印在页面上。

No clue if that helped but that is what I would do. 不知道是否有帮助,但这就是我会做的。

EDIT: for security reasons (SQL injections) use: 编辑:出于安全原因(SQL注入)使用:

filter_var($_GET["id"], FILTER_SANITIZE_SPECIAL_CHARS);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM