Reputation: 838
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. 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?
Upvotes: 1
Views: 119
Reputation: 246
Easy example is that you create link with GET parameter - like buyersdetails?id=X
X = ID of clicked user. and than at buyerdetails.php add some SQL statement which gets all data from database with id = X
Upvotes: 1
Reputation: 195982
Pass it as a url parameter..
<a href="buyersdetails.php?buyerid=<?php echo $row_buyerdetails['id'];?>">LINK HERE</a>
and in that page use $buyerid = $_GET['buyerid'];
and use it in your query
Upvotes: 1
Reputation: 164762
Assuming each buyer detail has a unique identifier (we'll use an integer id
for this example), something like this should suffice
<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']
.
Upvotes: 1