如何在PHP中从URL(GET)中删除和替换参数 [英] How to remove and replace parameter from URL (GET) in PHP

查看:84
本文介绍了如何在PHP中从URL(GET)中删除和替换参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

所以,假设我有这样的链接: www.mywebsite / products / index.php?p = 545



我想要的是这个链接: www.mywebsite / products / nameofproduct



所以在这里你看,当我点击特定产品的图片时,我的网站显示了一些产品,它重定向到上面的链接。你知道怎么做吗?



这是第一个链接的php代码。

查询(SELECT * FROM。$ TB_PRODUCTS。WHERE。$ PAYS。='1'AND Code ='。$ Format1。'); while($ dataF = $ Stat-> fetch(PDO :: FETCH_ASSOC)){
< a href = < span class =code-keyword> index.php?p =%3C?php%20echo%20 $ dataF [ > >

< / a >





我尝试过:



我读到了关于.htaccess的mod重写,但我从未使用过htaccess。

解决方案

TB_PRODUCTS。 WHERE。


PAYS。='1'AND Code ='。


Format1。'); while(

Hello,
So, let say that I have a link like this: www.mywebsite/products/index.php?p=545

What i want is to have this link : www.mywebsite/products/nameofproduct

So here as you see, my webiste is showing some products when I click in a picture of a specific product it redirect to the link above. Do you have any idea how to do it ?

Here is the php code for the first link.

query("SELECT * FROM ".$TB_PRODUCTS." WHERE ".$PAYS."='1' AND Code = '".$Format1."' "); while($dataF = $Stat->fetch(PDO::FETCH_ASSOC)){ 
<a href="index.php?p=%3C?php%20echo%20$dataF[">">

</a>



What I have tried:

I read about mod rewrite of the .htaccess but I never used htaccess.

解决方案

TB_PRODUCTS." WHERE ".


PAYS."='1' AND Code = '".


Format1."' "); while(


这篇关于如何在PHP中从URL(GET)中删除和替换参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆