Page 1 of 1

Select mysql data according to ID from URL address

Posted: 19 Jan 2017, 14:00
by JanMolendijk
I need your help again i cant find out how to select a specific id to show
i have this address: jan-molendijk.16mb.com/Notice/user/index.php?page=memberslist

Their standing two names when i click on one name it does not show the data from the selected name
On this page i have this code:

Code: Select all

    echo '<br /> <a href="http://jan-molendijk.16mb.com/Notice/user/index.php?page=users&id='. $row['id']. '" title="" class="postlink" target="_self"> '. $row['name']. '  '. $row['gender']. ' '. $row['dob']. '</a> ' ;
But it select only the same name when i click on someone name because i use the wrong code like this:

Code: Select all

<?php 
session_start();
include('../connection.php');
$user= $_SESSION['user'];
$sql=mysqli_query($conn,"select * from user where email='$user' ");
$users=mysqli_fetch_assoc($sql);
?>
<?php echo $users['name'];?>
I hope my English is understanble

Select mysql data according to ID from URL address

Posted: 19 Jan 2017, 14:51
by JanMolendijk
After day working i finaly found it out.
i added this code:

Code: Select all

$id = (int) $_GET['id'];
$sql = $conn->query("select * from user where id=$id");