mcclellanfsu Posted July 31, 2007 Share Posted July 31, 2007 Hello everyone, I have a pretty basic question for the experienced php programmer. I am new to PHP and have having some issues pulling information from my database. Here are my two database tables: tbl_team_roster soldier_id soldier_aaname soldier_combat_unit soldier_cposition soldier_status tbl_rank_assignment rank_id rank_name rank_obr rank_assigned_to (same as the member_id) My question here is I want a table that looks like this: Rank Game Name Status *rank image* my name active *rank image* another name active How do I combine the two tables to pull out the information I am looking for? Do I have the tables set up with the needed fields? Here is the code I have now...it is returning nothing (no errors, but no data). if ($action == "main" || $action == "") { $width = "width:100%"; $text .= " <div style='text-align:center'> <table style='".$width."' class='fborder' cellspacing='0' cellpadding='0'> <tr> <td style='width:80px' class='forumheader3'>".UM_LANG_RANK."</td> <td style='width:200px' class='forumheader3'>".UM_LANG_AANAME."</td> <td style='width:150px' class='forumheader3'>".UM_LANG_UNIT."</td> <td style='width:150px' class='forumheader3'>".UM_LANG_POSITION."</td> <td style='width:100px' class='forumheader3'>".UM_LANG_STATUS."</td> <td style='width:80px' class='forumheader3'></td> </tr>"; $sql->db_Select("team_roster", "*",""); $sql->db_Select("Ranks", "*", "ORDER BY rank_id",""); while($row = $sql->db_Fetch()){ $text .= " <tr> <td style='width:80px' class='forumheader3'><img src='images/smrank/".$row['rank_obr']."' alt = 'Rank'></img></td> <td style='width:100%' class='forumheader3'>".$row['soldier_aaname']."</td> <td style='width:80px' class='forumheader3'>".$row['soldier_combat_unit']."</td> <td style='width:100%' class='forumheader3'>".$row['soldier_cposition']."</td> <td style='width:80px' class='forumheader3'>".$row['soldier_status']."</td> <td style='width:100%' class='forumheader3'><a href='index.php?details.".$row['soldier_id']."'>".UM_LANG_DETAILS."</a></td> </tr>";} $text .= "</table> </div>"; $ns -> tablerender("3rdSFG Roster", $text); require_once(FOOTERF); Quote Link to comment https://forums.phpfreaks.com/topic/62705-question-regarding-pulling-info-from-a-database/ Share on other sites More sharing options...
mdnghtblue Posted July 31, 2007 Share Posted July 31, 2007 I'm not sure what all the "$sql->" stuff is, but this is how I would write it: if ($action == "main" || $action == "") { $width = "width:100%"; $text .= " <div style='text-align:center'> <table style='".$width."' class='fborder' cellspacing='0' cellpadding='0'> <tr> <td style='width:80px' class='forumheader3'>".UM_LANG_RANK."</td> <td style='width:200px' class='forumheader3'>".UM_LANG_AANAME."</td> <td style='width:150px' class='forumheader3'>".UM_LANG_UNIT."</td> <td style='width:150px' class='forumheader3'>".UM_LANG_POSITION."</td> <td style='width:100px' class='forumheader3'>".UM_LANG_STATUS."</td> <td style='width:80px' class='forumheader3'></td> </tr>"; $query = mysql_query("SELECT * FROM tbl_team_roster ORDER BY soldier_id;"); $ranks = mysql_fetch_array(mysql_query("SELECT rank_obr FROM tbl_rank_assignment ORDER BY rank_id;")); while($row = mysql_fetch_array($query)){ $text .= " <tr> <td style='width:80px' class='forumheader3'><img src='images/smrank/".current($ranks)."' alt = 'Rank'></img></td> <td style='width:100%' class='forumheader3'>".$row['soldier_aaname']."</td> <td style='width:80px' class='forumheader3'>".$row['soldier_combat_unit']."</td> <td style='width:100%' class='forumheader3'>".$row['soldier_cposition']."</td> <td style='width:80px' class='forumheader3'>".$row['soldier_status']."</td> <td style='width:100%' class='forumheader3'><a href='index.php?details.".$row['soldier_id']."'>".UM_LANG_DETAILS."</a></td> </tr>"; next($ranks);} $text .= "</table> </div>"; $ns -> tablerender("3rdSFG Roster", $text); require_once(FOOTERF); I'm not completely sure that'll work though. >.< Quote Link to comment https://forums.phpfreaks.com/topic/62705-question-regarding-pulling-info-from-a-database/#findComment-312125 Share on other sites More sharing options...
mcclellanfsu Posted July 31, 2007 Author Share Posted July 31, 2007 Thanks for the help, but it didn't work. Now I am getting this error: Parse error: syntax error, unexpected $end in /home/../.../.../team_roster/index.php on line 90 The thing is there is no line 90? <?php //-----------------------------------------------------------------------------------------------------------+ require_once("../../class2.php"); require_once(HEADERF); //-----------------------------------------------------------------------------------------------------------+ @include_once(e_PLUGIN."team_roster/languages/".e_LANGUAGE.".php"); @include_once(e_PLUGIN."team_roster/languages/English.php"); //-----------------------------------------------------------------------------------------------------------+ if (e_QUERY) { $tmp = explode('.', e_QUERY); $action = $tmp[0]; $sub_action = $tmp[1]; $id = $tmp[2]; unset($tmp); } //-----------------------------------------------------------------------------------------------------------+ if ($action == "main" || $action == "") { $width = "width:100%"; $text .= " <div style='text-align:center'> <table style='".$width."' class='fborder' cellspacing='0' cellpadding='0'> <tr> <td style='width:80px' class='forumheader3'>".UM_LANG_RANK."</td> <td style='width:200px' class='forumheader3'>".UM_LANG_AANAME."</td> <td style='width:150px' class='forumheader3'>".UM_LANG_UNIT."</td> <td style='width:150px' class='forumheader3'>".UM_LANG_POSITION."</td> <td style='width:100px' class='forumheader3'>".UM_LANG_STATUS."</td> <td style='width:80px' class='forumheader3'></td> </tr>"; $query = mysql_query("SELECT * FROM tbl_team_roster ORDER BY soldier_id;"); $ranks = mysql_fetch_array(mysql_query("SELECT rank_obr FROM rank_assignment ORDER BY rank_id;")); while($row = mysql_fetch_array($query)){ $text .= " <tr> <td style='width:80px' class='forumheader3'><img src='images/smrank/".current($ranks)."' alt = 'Rank'></img></td> <td style='width:100%' class='forumheader3'>".$row['soldier_aaname']."</td> <td style='width:80px' class='forumheader3'>".$row['soldier_combat_unit']."</td> <td style='width:100%' class='forumheader3'>".$row['soldier_cposition']."</td> <td style='width:80px' class='forumheader3'>".$row['soldier_status']."</td> <td style='width:100%' class='forumheader3'><a href='index.php?details.".$row['soldier_id']."'>".UM_LANG_DETAILS."</a></td> </tr>"; next($ranks);} $text .= "</table> </div>"; $ns -> tablerender("3rdSFG Roster", $text); require_once(FOOTERF); if ($action == "main" || $action == "") { $width = "width:100%"; $text .= " <div style='text-align:center'> <table style='".$width."' class='fborder' cellspacing='0' cellpadding='0'> <tr> <td style='width:80px' class='forumheader3'>".UM_LANG_RANK."</td> <td style='width:200px' class='forumheader3'>".UM_LANG_AANAME."</td> <td style='width:150px' class='forumheader3'>".UM_LANG_UNIT."</td> <td style='width:150px' class='forumheader3'>".UM_LANG_POSITION."</td> <td style='width:100px' class='forumheader3'>".UM_LANG_STATUS."</td> <td style='width:80px' class='forumheader3'></td> </tr>"; $query = mysql_query("SELECT * FROM tbl_team_roster ORDER BY soldier_id;"); $ranks = mysql_fetch_array(mysql_query("SELECT rank_obr FROM rank_assignment ORDER BY rank_id;")); while($row = mysql_fetch_array($query)){ $text .= " <tr> <td style='width:80px' class='forumheader3'><img src='images/smrank/".current($ranks)."' alt = 'Rank'></img></td> <td style='width:100%' class='forumheader3'>".$row['soldier_aaname']."</td> <td style='width:80px' class='forumheader3'>".$row['soldier_combat_unit']."</td> <td style='width:100%' class='forumheader3'>".$row['soldier_cposition']."</td> <td style='width:80px' class='forumheader3'>".$row['soldier_status']."</td> <td style='width:100%' class='forumheader3'><a href='index.php?details.".$row['soldier_id']."'>".UM_LANG_DETAILS."</a></td> </tr>"; next($ranks);} $text .= "</table> </div>"; $ns -> tablerender("3rdSFG Roster", $text); require_once(FOOTERF); Thanks for any help! Quote Link to comment https://forums.phpfreaks.com/topic/62705-question-regarding-pulling-info-from-a-database/#findComment-312140 Share on other sites More sharing options...
mcclellanfsu Posted August 1, 2007 Author Share Posted August 1, 2007 I'm still stuck on this...any help will be greatly appreciated. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/62705-question-regarding-pulling-info-from-a-database/#findComment-312786 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.