Solution benanamen Posted October 31, 2015 Solution Share Posted October 31, 2015 (edited) Ok, we are getting somewhere. Now, just use this code alone while you get things going. The difference is I have now added what is called a "Positional Placeholder" for username which is the question mark. There is another way to do it called "Named Parameters" but we can get into that another time. The code will now give you the individual column data. This is complete standalone with the connection code. Just practice with this. you can integrate it later. Set the connection parameters to your DB. <?phperror_reporting(-1);ini_set('display_errors', '1');$hostdb = 'localhost';$dbname = 'phphelp_joe';$username = 'root';$password = '';if (!empty($_GET['username'])) { $pdo = new PDO("mysql:host=localhost;dbname=$dbname", $username, $password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = "SELECT username, firstname, lastname, email FROM users WHERE username=?"; $stmt = $pdo->prepare($sql); $stmt->execute(array( $_GET['username'] )); $row = $stmt->fetch(); echo "{$row['username']} {$row['lastname']} {$row['email']}"; }else { echo 'No username in URL'; } ?> Edited October 31, 2015 by benanamen Quote Link to comment Share on other sites More sharing options...
JoeBrenan Posted October 31, 2015 Author Share Posted October 31, 2015 (edited) Yeah this works! It pulls in the username from the URL then displays the data relating to the username from the database on the page, and have implemented the code into the view_profile.php. Thanks a lot, i know it was hard work but i learned a lot Now to create a friends system Happy Halloween! Edited October 31, 2015 by JoeBrenan Quote Link to comment Share on other sites More sharing options...
benanamen Posted October 31, 2015 Share Posted October 31, 2015 (edited) Glad your learning. When I asked you for an SQL data dump this is what I was asking for: INSERT INTO `users` VALUES ('1', 'test', 'test', 'test', '5c73b9801c80c790e4c9b5bf0f55cdf84bea07baa3af1d778845427339d71e12', '4f0819657e64c9ed', ' test@test.com', '1', '2015-10-31', '1'); The reason I wanted your table AND data was so I could quickly and easily recreate your database on my server for testing and to make sure your tables are setup correctly. What I gave you is very basic code. It does not account for a nonexistent username among other things. Edited October 31, 2015 by benanamen Quote Link to comment Share on other sites More sharing options...
JoeBrenan Posted October 31, 2015 Author Share Posted October 31, 2015 (edited) yeah I know, I'm just using it to build some foundations to work off. Thanks again. don't suppose you could help me implement a basic friends link between users, with a request button? Edited October 31, 2015 by JoeBrenan Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.