Jump to content


Photo

help with a join table script


  • Please log in to reply
3 replies to this topic

#1 keithschm

keithschm
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 31 March 2006 - 02:44 PM

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


   $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

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

#2 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 31 March 2006 - 07:28 PM

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

#3 keithschm

keithschm
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 31 March 2006 - 07:35 PM

[!--quoteo(post=360451:date=Mar 31 2006, 02:28 PM:name=craygo)--][div class=\'quotetop\']QUOTE(craygo @ Mar 31 2006, 02:28 PM) View Post[/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
NEED HELP

#4 keithschm

keithschm
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 03 April 2006 - 12:04 PM

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
NEED HELP




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users