Log in

View Full Version : How to get username from userid


MikesSite
04-15-2009, 02:33 AM
I'm creating a php page for the forum that will show everybody from a specific string they input under the Additional Information / Details section. It's 'field2' located in the 'userfield' section of the forum database. Basically I am able to get the field2 string and userid, but I'm wondering how I can get the username from the userid?

if ($row['field2']=="United States") {
echo "<b>" . $row['userid'] . "</b> - <u>" . $row['field2'] . "</u>";
}

Thanks.

vbplusme
04-15-2009, 03:31 AM
Assuming you are selecting user.username in your query $row['username']

Am I missing something?

MikesSite
04-15-2009, 03:53 AM
selecting by userfield, there is no username row

mysql_select_db("forum") or die(mysql_error());
$b="SELECT * FROM userfield ORDER BY userid ASC";