Jump to content

help with a join table script


keithschm

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
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.