Jump to content

Reference a different record of the same table during a list program


utahfriend

Recommended Posts

My client wants me to add some detail to a program that someone else wrote. 

The table has three fields that are relavent: member_number, name, sponsor_number

 

The sponsor_number corresponds to a record in the same table where member_number is the same as the sponsor_number

 

The client wants a report that will list all the members as such:

$member_number  -  $name  -  $Sponsor_number  $sponsors name (name relating the the member_number which matches the sponsor_number)

 

The code that is in use now to list the members (does not list the sponsors name, which I need to find out how to add that):

while ($q->next_record()) {
   $j++;
   if ($j == 1)  $t->set_var("nr_lvl", '					
      <tr>
<td colspan="7" bgcolor=#efefef>Level 1</td>
      </tr>');
   else  $t->set_var("nr_lvl", "");
      $t->set_var("id", $q->f("id"));
      $name = $q->f("first_name")." ".$q->f("last_name");
      $t->set_var("name", $name);
      if (get_setting("downline_em")) {
$t->set_var("email", "<td>Home: ".$q->f("home_phone")."<br>Cell: ".$q->f("cell_phone")."</td><td>".$q->f("email")."</td>");
      } else {$t->set_var("email", "");}

      $sponsor = $q->f("first_name")." ".$q->f("last_name");
      $t->set_var("sponsor", $sponsor);
      $t->parse("downline_rows", "downline_row_file", true);
   }

 

How is the best way to pull the name of the sponsor in the middle of the above list function?

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.