php 如何使用php从URL获取id
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24396712/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to get id from URL using php
提问by user3772864
I have this code on my Search page:
我的搜索页面上有此代码:
<a href="detail.php?id=<?php echo $ido;?>"STYLE="TEXT-DECORATION: NONE"><?php echo $nume;?></a>
and i also have a detail.php
page. I need to get the $ido
value from the URL so that I can use it in the detail.php
page to retrieve information from the database.
我也有一个detail.php
页面。我需要$ido
从 URL获取值,以便我可以在detail.php
页面中使用它从数据库中检索信息。
The detail page has a URL like this: detail.php?id=17
, I need to get the value after the =
, in this case 17
, into a variable.
详细信息页面有一个这样的 URL:detail.php?id=17
,我需要将 之后的值=
(在本例中17
)放入一个变量中。
回答by Kinnectus
In your detail.php use: $id = $_GET['id'];
you can then use $id
around the rest of your page.
在您的 detail.php use:$id = $_GET['id'];
然后您可以$id
在页面的其余部分使用。