Giovanni
Giovanni

Reputation: 838

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:

enter image description here

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

Answers (3)

KiwixLV
KiwixLV

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

Gabriele Petrioli
Gabriele Petrioli

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

Phil
Phil

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

Related Questions