0

I have a code here where the referral name of each person has a hyperlink and when i click it, it will go to pick.php. For example I click "TEST7 TEST7", how do I pass the Lead No. of "TEST7 TEST7" which is LEA3330 to pick.php?

Picture

part of code in index.php

//print data in the table
echo '
<tr>
<td>'.$row['lead_no'].'</td>
<td><a href="pick.php"> '.$row['firstname'].' '.$row['lastname'].'</a></td>
</tr>
';
marse
  • 863
  • 2
  • 10
  • 22

4 Answers4

2

You can use $_GET:

//print data in the the table
echo
"<tr>
    <td>{$row['lead_no']}</td>
    <td>
        <a href='pick.php?lead_no={$row['lead_no']}'>
            {$row['firstname'].$row['lastname']}
        </a>
    </td>
</tr>";

Then, access it from pick.php like so:

$lead_no = $_GET['lead_no'];

For future reference: GET URL parameter in PHP

Community
  • 1
  • 1
Huey
  • 5,110
  • 6
  • 32
  • 44
0

Pass the value as a get parameter:

<a href="pick.php?leadno=<?php echo $row['lead_no']; ?>">   

and then just use $_GET['leadno']

taxicala
  • 21,408
  • 7
  • 37
  • 66
0

You can pass data in the URL as query parameters. For example, instead of next.php, go to next.php?key=value&key2=value2. So when you're generating the page with the hyperlink, create a link with that extra part (it'll need to be URL encoded, also).

Then, you can use the special $_GET array in the next.php page to access those variables. For example, $_GET['key'].

Note that you shouldn't send anything private in the query params, or anything that you wouldn't want someone to bookmark, share the link to, etc. So you mustn't use query params to submit forms, say. Read up on GET versus POST here.

Luke
  • 1,724
  • 1
  • 12
  • 17
0

In pick.php just use the $_GET['leadno'];

Fiido93
  • 1,918
  • 1
  • 15
  • 22