graham23s Posted March 7, 2007 Share Posted March 7, 2007 Hi Guys, I was wondering if anyone can point me in the right direction here, i am making a very small site here (to throw all i am learning with PHP) together into something constructive all is going good so far but after i have a user sign up from the form the details are getting stored in the database ok, but i was wanting to give each of the users an i so when somebody clicks they're name theyre taken to they're page i.e www.sitename.com/users.php?user=12345 That kinda thing but i have no idea on what part/tutorial i should read for this any help would be appreciated. cheers Graham Link to comment https://forums.phpfreaks.com/topic/41586-giving-each-member-an-id/ Share on other sites More sharing options...
skali Posted March 7, 2007 Share Posted March 7, 2007 You can create an id field in your table. Type of this field can be 'int'. This field will be the primary key of the table and rest of the fields will have the other user details. Link to comment https://forums.phpfreaks.com/topic/41586-giving-each-member-an-id/#findComment-201523 Share on other sites More sharing options...
graham23s Posted March 7, 2007 Author Share Posted March 7, 2007 Hi Mate, yep done that part ok , the very first field is "user_id" with auto_increment, what i was thinking was when i paginate or do a search for a user to make his/her name clickable (so when theyre name is clicked it takes them to the users details) i think its something like: <a href="user.php">graham23s</a>. user_id . ^ excuse the bad coding i have no idea after that lol cheers for nay help Graham Link to comment https://forums.phpfreaks.com/topic/41586-giving-each-member-an-id/#findComment-201536 Share on other sites More sharing options...
skali Posted March 7, 2007 Share Posted March 7, 2007 <a href='url.php?id=<?= $id_from_db ?>'><?= $user_name_from_db?></a> Link to comment https://forums.phpfreaks.com/topic/41586-giving-each-member-an-id/#findComment-201541 Share on other sites More sharing options...
graham23s Posted March 7, 2007 Author Share Posted March 7, 2007 Hi Skali, Thats great, thats exactly what i'm after i have done this on a test page: <?php // Database information $host = 'localhost'; $user = 'root'; $pass = 'xxxxxx'; $data = 'xxx'; // Connect and select the database. $conn = mysql_connect($host, $user, $pass) or die(mysql_error()); $db = mysql_select_db($data, $conn) or die(mysql_error()); // User from database... echo "<a href='url.php?id=<?= $user_id ?>'><?= $username?></a>"; ?> But still nothing showing up when i execute it, is there anything iam missing? cheers Graham Link to comment https://forums.phpfreaks.com/topic/41586-giving-each-member-an-id/#findComment-201553 Share on other sites More sharing options...
brown2005 Posted March 7, 2007 Share Posted March 7, 2007 $profile = "SELECT * FROM members;"; $profile_query = mysql_query($profile) or die(mysql_error()); while($profile_array = mysql_fetch_array($profile_query)) { echo "<a href='url.php?id=$profile_array[id]'>$profile_array[username]</a>"; } you have to get the info from the database. Link to comment https://forums.phpfreaks.com/topic/41586-giving-each-member-an-id/#findComment-201557 Share on other sites More sharing options...
graham23s Posted March 7, 2007 Author Share Posted March 7, 2007 Hi, Thanks a lot mate that has worked perfectly, the only other thing is once the users name is clicked it's suppose to take them to that particular users page from there i will query the database and display that users signup info, what is the best way to do that at all? just the basics of what needs done would be great i shall read up from there. thanks again mate Graham Link to comment https://forums.phpfreaks.com/topic/41586-giving-each-member-an-id/#findComment-201566 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.