loonie35 Posted November 20, 2008 Share Posted November 20, 2008 How to do that? Link to comment Share on other sites More sharing options...
jeffman Posted November 20, 2008 Share Posted November 20, 2008 Provide more information, please. Link to comment Share on other sites More sharing options...
vytas Posted November 20, 2008 Share Posted November 20, 2008 We can't work with this information :S Link to comment Share on other sites More sharing options...
loonie35 Posted November 20, 2008 Author Share Posted November 20, 2008 i have table users and i want to view some other user and his information there listed in that page, something like user.php?id=userid Link to comment Share on other sites More sharing options...
jeffman Posted November 20, 2008 Share Posted November 20, 2008 i have table users and i want to view some other user and his information there listed in that page, something like user.php?id=useridIf you did it that way, you'd find the user ID here: $_GET['id']Is your DB mysql? Do you need help with that? What's the name of the column that holds the user ID? Link to comment Share on other sites More sharing options...
loonie35 Posted November 20, 2008 Author Share Posted November 20, 2008 I have MySQL here is my table conents CREATE TABLE `users` ( `id` int(255) NOT NULL auto_increment, `username` varchar(255) collate utf8_latvian_ci NOT NULL, `age` varchar(255) collate utf8_latvian_ci NOT NULL, `picture` varchar(255) collate utf8_latvian_ci NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_latvian_ci AUTO_INCREMENT=3; I tryed to make something like that: $id = $_GET['userid']; if (isset($_GET['id']) and $_GET['id'] == "$id") { $r = mysql_query("SELECT * FROM users"); while ($row = mysql_fetch_assoc($r)) { echo $row['username']; }; } but just shows blank page. Link to comment Share on other sites More sharing options...
jeffman Posted November 20, 2008 Share Posted November 20, 2008 I adapted this from the PHP manual. You'll need to change the values to make the correct connection and select the correct database.. $conn = mysql_connect("localhost", "mysql_user", "mysql_password");if (!$conn) { echo "Unable to connect to DB: " . mysql_error(); exit;} if (!mysql_select_db("mydbname")) { echo "Unable to select mydbname: " . mysql_error(); exit;}$id = $_GET['id'];$sql = "SELECT * FROM users WHERE id = $id";$result = mysql_query($sql);if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit;}if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit;}while ($row = mysql_fetch_assoc($result)) { echo $row["id"]; echo $row["username"]; echo $row["age"]; echo $row["picture"];} Link to comment Share on other sites More sharing options...
loonie35 Posted November 20, 2008 Author Share Posted November 20, 2008 Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.