php 如何通过url发送id

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26070699/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 18:08:02  来源:igfitidea点击:

How to send id through url

phpcodeigniterurlactiverecord

提问by Muhammad Subhan Khan

I want to send my id through url and want to get id in another page.

我想通过 url 发送我的 id 并想在另一个页面中获取 id。

But how to send id through url Kindly help.

但是如何通过 url 发送 id 请帮忙。

My Views which is not working.

我的观点不起作用。

<div class='title'><a href="<?php echo $Result->ad_id();?>"><?php echo ucwords($Result->ad_title);?></a></div>

回答by alagu

Lets assume,

让我们假设,

your domain name is http://www.muhammad.com

您的域名是 http://www.muhammad.com

You are going pass id to index.php

你要把 id 传递给 index.php

<div class='title'>
    <a href="http://www.muhammad.com/index.php?id=<?php echo $Result->ad_id();?>"><?php echo ucwords($Result->ad_title);?></a>
</div>

In index.php

在 index.php 中

$submit_id = $_GET['id'];

回答by Tahsin Abrar

This is your given code.

这是您给定的代码。

<div class='title'>
   <a href="<?php echo $Result->ad_id();?>">
      <?php echo ucwords($Result->ad_title);?>
   </a>
</div>

Here, the hyperlink is not correct. If you're using php without any framework, then add the link first before the id you want to pass.

在这里,超链接不正确。如果您使用的是没有任何框架的 php,那么请先在您要传递的 id 之前添加链接。

<a href="http://example.com/anypage.php?id=<?php echo $Result->ad_id();?>">
   <?php echo ucwords($Result->ad_title);?>
</a>

Now, in the anypage.php, write some code to get the id from the url, i.e.

现在,在 anypage.php 中,编写一些代码来从 url 中获取 id,即

$id= $_GET("id");

$id= $_GET("id");

Hope, it'll work! :)

希望,它会奏效!:)

回答by wookie919

This will help:

这将有助于:

data is not passing through url

数据不通过 url

As an example, to pass id = 1234to test.php:

例如,传递id = 1234test.php

test.php?id=1234

test.php?id=1234

Then in test.php, the value of idwill be available from $_GET['id'].

然后在 中test.php, 的值id将从 中可用$_GET['id']

回答by Kiyarash

<div class='title'>
    <a href="<?php echo $Result->ad_id() . '?variable_name=variable_value' ?> "></a>
</div>

This is one way of query string for passing data using GETmethod...

这是使用GET方法传递数据的查询字符串的一种方式......

protocol://domain_name?variable_name=variable_value

protocol://domain_name?variable_name=variable_value

for example:

http://test.com?sid=128001

例如:

http://test.com?sid=128001

So you can fetch the value in other page:

所以你可以在其他页面中获取值:

$var = $_GET['variable_name'];
//in this case:
$var = $_GET['sid'];