Jump to content

Archived

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

keithschm

help with a join table script

Recommended Posts

i am writhing a script for my CMS. I have 2 tables that I have to get information from. the second query gets it WHERE from the first. I tried using two whiles but it stops after the first entry. have a look

[code]

   $text .= "<div style='width:100%'><table style='width:100%' class='fborder' align='center' cellspacing='0' cellpadding='0'>";

     $sql -> db_Select("user_extended ", "*", "user_XFIRE !='' ");
         while($row = $sql-> db_Fetch()){//first loop

            $text .="<tr>";
            $text .="<td class='forumheader3'><img src='http://miniprofile.xfire.com/bg/".$xfire_style."/type/".$xfire_size."/".$row['user_XFIRE'].".png'></td>";

//=======================================

     $sql -> db_Select("user ", "*", "user_id ='".$row['user_extended_id']."'");
while($row3 = $sql-> db_Fetch()){//second loop

            $text .="<tr>";
            $text .="<td class='forumheader3'>".$row3['user_name']."</td>";

         }//end second loop



//==================================


         }//end firstloop[/code]

Is my while wrong or do I need a left join or something. I am not sure how to format the join

Share this post


Link to post
Share on other sites
Is there a common field to link the 2 tables. You need to have something to link the 2 together.

Give a little snippet of your table structure and field names.

Ray

Share this post


Link to post
Share on other sites
[!--quoteo(post=360451:date=Mar 31 2006, 02:28 PM:name=craygo)--][div class=\'quotetop\']QUOTE(craygo @ Mar 31 2006, 02:28 PM) [snapback]360451[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Is there a common field to link the 2 tables. You need to have something to link the 2 together.

Give a little snippet of your table structure and field names.

Ray
[/quote]


yes

table user has

user_id
user_name

table user_extended has

user_extended_id
user_xfire

user_extended_id and user_id are the same rather the user ID of the user.
so I want to get the user_name of the user_id that is the same id as user_extended_id

Share this post


Link to post
Share on other sites
I have been searching for how to write a join statement in php. all I could find is how to do it in mysql

anybody know how to for a join script?

thanks

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.