Jump to content

Recommended Posts

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);

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. >.<

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!

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.