Jump to content

Giving each member an id.


graham23s

Recommended Posts

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

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

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

$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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.