I have 2 tables, one called posts and one called users. Inside posts I have several columns, one being a foreign key of userid. In my users table I have several columns including a userid and a username. I want to use the posts.userid to find the users.userid and show users.username. Currently I am using:
SELECT posts.postid, posts.title, posts.text, posts.link, posts.good, posts.bad, posts.userid
FROM posts
To get the data about each post and,
SELECT users.username, users.userid, posts.userid
FROM users, posts
WHERE users.userid = posts.userid
to get the data about each user, but when I do this the output of echo $row_therealuserid['username']; is always just the first user.
$row_therealuseridcome from?