CBaZ Posted July 18, 2007 Share Posted July 18, 2007 *** = 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"; ?> Quote Link to comment Share on other sites More sharing options...
CBaZ Posted July 18, 2007 Author Share Posted July 18, 2007 <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 Quote Link to comment Share on other sites More sharing options...
CBaZ Posted July 18, 2007 Author Share Posted July 18, 2007 actually its either the first or 2nd row from my users table how do i make it select the right id with the right username Quote Link to comment 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.