Jump to content


This topic is now archived and is closed to further replies.


MySQL table join help

Recommended Posts

mysql_connect($db_host, $db_user, $db_pass);
$sql = "SELECT * FROM news_site LEFT JOIN staff ON news_site.poster = staff.id WHERE news_site.show = '1' ORDER BY news_site.posted desc LIMIT 10";
$results = mysql_query($sql);
$rowcount = mysql_num_rows($results);
$i = "0";
while ($data = mysql_fetch_array($results)) {
    print "<u>$data[title]</u><br>";
    print "$data[post]<br><br>";
    print DateConvert($data['posted'], "l, jS F Y @ H:i:s");
    if ($i != $rowcount) {
        print "<hr noshade size=1 color=#3366cc>";
    } else {

So thats all good, but what i also want is to be able to fetch the staff.displayname for each news_site.poster, if that makes sense.

Thanks in advance,

Share this post

Link to post
Share on other sites


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.