Assorro Posted March 16, 2009 Share Posted March 16, 2009 Greetings everyone. I started a project last weekend and I am looking for a community that is capable of helping me when I run into snags using php as I am quite new to it. I have created a login system using MySql which allows members to register an account and the program by default places that account within a starting group. Registered members will be able to create their own group in the future which other members can switch to if they choose. I realized last night that it is easy enough to list all the members within a group but I don't know how to turn those names into links so that when clicked, the members personal page is displayed. I want to study how to make the links so that they look like this: http://www.somesite.com/members.php?user=someuser I had the same problem with record paging. I just didn't know what it was called so I couldn't study it around the net. Is there a specific name used to refer to this? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/149612-turning-db-records-into-links/ Share on other sites More sharing options...
Daniel0 Posted March 16, 2009 Share Posted March 16, 2009 Well, if you can make a list of usernames then making a list of links to user profiles is essentially the same. Sort of like: $db = new mysqli('localhost', 'user', 'password', 'database_name'); if ($result = $db->query('SELECT username FROM users WHERE user_id = 5')) { echo '<ol>'; while($user = $result->fetch_assoc()) { echo '<li><a href="' . htmlentities(urlencode($user['username'])) . '">' . htmlentities($user['username']) . '</a></li>'; } echo '</ol>'; } else { echo '<p>There are no users in this group.</p>'; } Quote Link to comment https://forums.phpfreaks.com/topic/149612-turning-db-records-into-links/#findComment-785644 Share on other sites More sharing options...
Assorro Posted March 16, 2009 Author Share Posted March 16, 2009 Okay, keeping in mind that I am fresh out of the box with php I have a need to study everything from the grass roots up ... and I have a long way to go. I plugged in the database info and ran the script as a standalone to study it but received "Fatal error: Class 'mysqli' not found in...." My guess is that I have not defined parameters for mysqli but then again, I'm all at sea here. Thanks Daniel0. Quote Link to comment https://forums.phpfreaks.com/topic/149612-turning-db-records-into-links/#findComment-785676 Share on other sites More sharing options...
Daniel0 Posted March 16, 2009 Share Posted March 16, 2009 You can use the old mysql extension instead of the new mysqli (MySQL improved) if you wish. You'll also have to modify the query to fit your needs. It was a sample snippet and not supposed to be used verbatim. You'll also have to do error handling and such. Quote Link to comment https://forums.phpfreaks.com/topic/149612-turning-db-records-into-links/#findComment-785678 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.