[英]Multiple links to the same page but with different information on it
I have a table which is created 'on the fly' from a database using the following code: 我有一个使用以下代码从数据库中“动态”创建的表:
<tr>
<td><?php echo $row_buyerdetails['time_stamp']; ?></td>
<td><?php echo $row_buyerdetails['title']; ?></td>
<td><?php echo $row_buyerdetails['first_name']; ?></td>
<td><?php echo $row_buyerdetails['surname']; ?></td>
<td><?php echo $row_buyerdetails['email_address']; ?></td>
<td><?php echo $row_buyerdetails['phone_number']; ?></td>
<td><?php echo $row_buyerdetails['house']; ?></td>
<td><?php echo $row_buyerdetails['street']; ?></td>
<td><?php echo $row_buyerdetails['town']; ?></td>
<td><?php echo $row_buyerdetails['city']; ?></td>
<td><?php echo $row_buyerdetails['postcode']; ?></td>
<td>**LINK IN HERE**</td>
</tr>
<?php } while ($row_buyerdetails = mysql_fetch_assoc($result)); ?>
</table>
The code produces a table with the buyers basic details in it as shown below: 该代码生成一个表,其中包含买家的基本详细信息,如下所示:
In the cells with the text "LINK IN HERE" I want a link to a page called buyerdetails.php which will show all the information about that person. 在文本“LINK IN HERE”的单元格中,我想要一个名为buyerdetails.php的页面链接,该页面将显示有关该人的所有信息。 How do I create the link so that it passes an identifying value to the page buyersdetails.php so that page knows which users details to look up in the database and display them?
如何创建链接以便将标识值传递给页面buyerdetails.php,以便页面知道在数据库中查找哪些用户详细信息并显示它们?
Assuming each buyer detail has a unique identifier (we'll use an integer id
for this example), something like this should suffice 假设每个买家详细信息都有一个唯一的标识符(我们将在这个例子中使用整数
id
),这样的东西就足够了
<td>
<a href="buyerdetails.php?id=<?= (int) $row_buyerdetails['id'] ?>">More Details</a>
</td>
On buyerdetails.php
, you can then retrieve the value via $_GET['id']
. 在
buyerdetails.php
,您可以通过$_GET['id']
检索该值。
Pass it as a url parameter.. 将其作为url参数传递给..
<a href="buyersdetails.php?buyerid=<?php echo $row_buyerdetails['id'];?>">LINK HERE</a>
and in that page use $buyerid = $_GET['buyerid'];
并在该页面中使用
$buyerid = $_GET['buyerid'];
and use it in your query 并在您的查询中使用它
Easy example is that you create link with GET parameter - like buyersdetails?id=X 简单的例子是你用GET参数创建链接 - 比如buyerdetails?id = X.
X = ID of clicked user. X =已点击用户的ID。 and than at buyerdetails.php add some SQL statement which gets all data from database with id = X
而且在buyerdetails.php中添加了一些SQL语句,它从id = X的数据库中获取所有数据
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.