-1

I need to show particular persons info on the next page info.php by clicking the name which is inside the anchor tag. So how can i pass the value of id of that person on the next page and retrieve data from it.

<tr>
    <?php 
        while($row = mysqli_fetch_assoc($result)){

            echo '<tr>';
            echo '<td>'.$row['id'].'</td>';
            echo '<td><a href="">'.$row['name'].'</a></td>';
            echo '<td>'.$row['username'].'</td>';
            echo '<td>'.$row['password'].'</td>';

            echo '</tr>';
        }
    ?>
</tr>
Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159
Rinku Malik
  • 71
  • 1
  • 7

3 Answers3

0

Pass:

echo "<td><a href='info.php?id={$row['id']}'>" . $row['name'] . '</a></td>';

Get:

mysqli_real_escape_string($_GET['id'])
Ilya Hoilik
  • 154
  • 1
  • 5
  • can u please also tell me how to save this value in a variable on the page info.php.? Should i use $_POST or $_GET method. – Rinku Malik Apr 06 '17 at 17:02
  • updated my answer, you can use $_GET, but make sure you use mysqli_real_escape_string – Ilya Hoilik Apr 06 '17 at 17:03
  • can u pls help me undrstnd the above code of passing value – Rinku Malik Apr 06 '17 at 17:04
  • You can add `$row['id']` variable value between quotes ( `" "` ), placing it around the braces ( `{ }` ). For understanding this you should probably read this answer http://stackoverflow.com/questions/2596837/curly-braces-in-string-in-php – Ilya Hoilik Apr 06 '17 at 17:10
0

code here:

    while ($row = mysqli_fetch_array($result)) {
     echo "<a href='edit-main-con.php?edit=$row[id]'>Done</a><br>";
    }
MAhipal Singh
  • 4,745
  • 1
  • 42
  • 57
-1

Get the value that is passed through the anchor tag. The id is the name that contained an id:

$X=$_GET['ID'];
echo $X;
JSON C11
  • 11,272
  • 7
  • 78
  • 65