keithschm Posted March 31, 2006 Share Posted March 31, 2006 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 https://forums.phpfreaks.com/topic/6272-help-with-a-join-table-script/ Share on other sites More sharing options...
craygo Posted March 31, 2006 Share Posted March 31, 2006 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 Link to comment https://forums.phpfreaks.com/topic/6272-help-with-a-join-table-script/#findComment-22725 Share on other sites More sharing options...
keithschm Posted March 31, 2006 Author Share Posted March 31, 2006 [!--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_iduser_nametable user_extended has user_extended_iduser_xfireuser_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 https://forums.phpfreaks.com/topic/6272-help-with-a-join-table-script/#findComment-22729 Share on other sites More sharing options...
keithschm Posted April 3, 2006 Author Share Posted April 3, 2006 I have been searching for how to write a join statement in php. all I could find is how to do it in mysqlanybody know how to for a join script?thanks Link to comment https://forums.phpfreaks.com/topic/6272-help-with-a-join-table-script/#findComment-23446 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.