PHP MySQL query help

Posted by user547794 on Stack Overflow See other posts from Stack Overflow or by user547794
Published on 2011-01-01T04:51:27Z Indexed on 2011/01/01 4:53 UTC
Read the original article Hit count: 203

Filed under:
|

Hello,

I am trying to use this query to return every instance where the variable $d['userID'] is equal to the User ID in a separate table, and then echo the username tied to that user ID.

Here's what I have so far:

$uid = $d['userID'];

$result = mysql_query("SELECT u.username
FROM users u
LEFT JOIN comments c
ON c.userID = u.id
WHERE u.id = $uid;")$row = mysql_fetch_assoc($result);
echo $row['username'];

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql