Jump to content

viewing other members profile


CBaZ

Recommended Posts

*** = not sure what to place here yet.  i get the read out of all my usernames via the id but i need maybe another row in my table to make this work. please help me  :)

 

 

<?php

echo "</left><form name=\"profileview\" action=\"profile.php?user_id=***\" method=\"post\">\n";

echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";

echo "<tr>\n";

echo "<td>View:</td>\n";

echo "<td><select name=\"profile\">\n";

echo "<option value=\"\"></option>\n";

 

 

$sql = mysql_query("SELECT * FROM users WHERE user_id != '$_SESSION[id]' ORDER BY username");

if (mysql_num_rows($sql) > 0) {

  while ($x = mysql_fetch_assoc($sql)) echo "<option value=\"$x[user_id]\">$x[username]</option>\n";

}

 

echo "</td>\n";

echo "</tr>\n";

echo "<tr>\n";

echo "<td></td>\n";

echo "<td><input type=\"submit\" name=\"profileview\" value=\"View\" /></td>\n";

echo "</tr>\n";

echo "</table>\n";

echo "</form></left>\n";

 

?>

Link to comment
https://forums.phpfreaks.com/topic/60601-viewing-other-members-profile/
Share on other sites

<br>

<?php

$connect = mysql_connect("localhost", "user", "pw") or die("Could not connect to database: " . mysql_error());

mysql_select_db("db", $connect) or die("Could not select database");

$query = "SELECT * FROM users WHERE user_id != '$user_id' ORDER BY username"; 

$result = mysql_query($query, $connect) or die("QUERY FAILED: " . mysql_error());

$row = mysql_fetch_array($result,MYSQL_ASSOC);

print "<left><form name=\"profileview\" action=\"profile2.php?user_id=$row[user_id]\" method=\"post\">\n";

echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";

echo "<tr>\n";

echo "<td>View:</td>\n";

echo "<td><select name=\"profileview\">\n";

echo "<option value=\"\"></option></left>\n";

 

 

$sql = mysql_query("SELECT * FROM users WHERE user_id != '$_SESSION[id]' ORDER BY username");

if (mysql_num_rows($sql) > 0) {

  while ($x = mysql_fetch_assoc($sql)) echo "<option value=\"$x[user_id]\">$x[username]</option>\n";

}

 

echo "</td>\n";

echo "</tr>\n";

echo "<tr>\n";

echo "<td></td>\n";

echo "<td><input type=\"submit\" name=\"profileview\" value=\"View\" /></td>\n";

echo "</tr>\n";

echo "</table>\n";

echo "</form></left>\n";

 

?>

 

the question is that i can only get the current logged in user's id but i want it to be the user id matching the username that comes up from the pull down list.  the usernames show up but the user id won't be displayed when i select a username from the pulldown

 

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.