Jump to content

Question


Immortal55

Recommended Posts

I would suggest that you have a "members" page that is sorted some way - even if it just sorts them by id descending. Each member's username would be a link to something like /profile.php?user="usernamehere"..
Then you could populate sections of that page by getting the member's info from the database.

Something like:


[code]$sql = mysql_query("SELECT * FROM members WHERE username='{$_REQUEST['user']}'");[/code]

then you could simply use a while loop to make the user's info into simply variables:

[code]while($row = mysql_fetch_assoc($sql)){

//this next line will make all the array variables into normal variables - if you had a "last_name" field in the database you could now call it simply by using $last_name
stripslashes(extract($row));

echo $username;
echo $last_name;
}
[/code]

This is just an example of how to do it, not full blown code as I have neither the time, or your database setup etc... Anyway, if you need any more help, just ask :)

-austen
Link to comment
https://forums.phpfreaks.com/topic/4927-question/#findComment-17378
Share on other sites


alright, so if I wanted to have links to user profiles from my db, where the table with the info is titled users, and in the table the names i want displayed are under 'uname' then would my script look like this:

[code]
<?

$conn = db_connect();
if (!$conn)
    return false;
    
    $sql = mysql_query("SELECT * FROM users WHERE
        uname = '{$_REQUEST['user']}'");
        
    while($row = mysql_fetch_assoc($sql){
    stripslashes(extract($row));
    
    echo '<a href="/profile/profile.php?user='.$uname.'>'.$uname.'</a>';
    
}

?>
[/code]

if anything is wrong, please help me out.
Link to comment
https://forums.phpfreaks.com/topic/4927-question/#findComment-17601
Share on other sites

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.