// Database connection by using PHP PDO require_once("../config/db.php"); // File containing database connection credentials. try { $dbh = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PASS); } catch (PDOException $e) { exit("Error: " . $e->getMessage()); } // using this handler above. // Get the userid $userid = intval($_GET['id']); $sql = "SELECT FirstName,LastName,EmailId,ContactNumber,Address,PostingDate,id from tblusers where id=:uid"; //Prepare the query: $query = $dbh->prepare($sql); //Bind the parameters $query->bindParam(':uid', $userid, PDO::PARAM_STR); //Execute the query: $query->execute(); //Assign the data which you pulled from the database (in the preceding step) to a variable. $results = $query->fetchAll(PDO::FETCH_OBJ); if ($query->rowCount() > 0) { //In case that the query returned at least one record, we can echo the records within a foreach loop: foreach ($results as $result) { // Print the rows. echo "
"; echo htmlentities($result->FirstName); echo htmlentities($result->LastName); } } else { echo "No rows returned."; }