1

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?

Giovanni
  • 850
  • 3
  • 14
  • 32
  • 1
    Please read this - [Why shouldn't I use mysql_* functions in PHP?](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) – Phil Feb 23 '14 at 22:57

3 Answers3

1

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'].

Phil
  • 157,677
  • 23
  • 242
  • 245
  • sorry I couldnt accept your answer, I went with first come, first serve im afraid :) – Giovanni Feb 23 '14 at 23:07
  • @Giovanni If you really want to honour the first answer, check the timestamps next time. I'm a good 8 seconds prior to Gaby ;) – Phil Feb 23 '14 at 23:07
  • @Giovanni If you hover the answer time, you get a full timestamp. Mine - `22:54:39Z`, Gaby's - `22:54:47Z`. Don't go changing your vote though, doesn't bother me when the answers are that close together – Phil Feb 23 '14 at 23:52
1

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

Gabriele Petrioli
  • 191,379
  • 34
  • 261
  • 317
1

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

KiwixLV
  • 226
  • 1
  • 5