Current location: Hot Scripts Forums » Programming Languages » PHP » MySQL table join and php


MySQL table join and php

Reply
  #1 (permalink)  
Old 04-09-06, 02:19 PM
xtheonex xtheonex is offline
New Member
 
Join Date: Apr 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation MySQL table join and php

PHP Code:

<?

mysql_connect
($db_host$db_user$db_pass);
mysql_select_db($db_name);
$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)) {
    
$i++;
    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>";
    }
}
?>
Right so thats all good, however i need to fetch the posters display name from the "staff" table. I am new to using table joins so this is probably quite simple for those of you who have been doing it for a while.

Thanks in advance,
Dave

Last edited by Christian; 04-09-06 at 05:13 PM. Reason: PLEASE USE [PHP][/PHP] WHEN POSTING PHP CODE!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP + MySQL Developer / Support (Sydney). Good $$. Interspire Job Offers & Assistance 0 01-18-06 12:13 AM
Interspire is looking for a highly motivated PHP expert 2 join our young dynamic team Interspire Job Offers & Assistance 0 06-16-05 07:38 PM
C/C++ - 2D/3D Designers - PHP Mysql Web Design Required KingsZone Job Offers & Assistance 2 09-13-04 04:00 PM
looking for 3 or 4 PHP programmers to join my dev. team Dizzy Spinalot PHP 4 10-13-03 04:27 AM


All times are GMT -5. The time now is 12:16 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.