News: TinyPortal Release Schedule. Please read this update for More Info.

Login  |  Register
HTML5 Icon HTML5 Icon
TP on Social Media
Welcome, Guest. Please login or register.
Did you miss your activation email?

November 14, 2019, 07:07:15 AM

Login with username, password and session length

Recent

Members
Stats
  • Total Posts: 189259
  • Total Topics: 20772
  • Online Today: 435
  • Online Ever: 629
  • (November 08, 2018, 01:36:54 PM)
Users Online
Users: 0
Guests: 49
Total: 49

Author Topic: Listing specific members in php artical  (Read 11948 times)

0 Members and 1 Guest are viewing this topic.

JPDeni

  • Guest
Re: Listing specific members in php artical
« Reply #30 on: October 12, 2008, 05:07:14 PM »
I'll see if I can add all this to my test site and work on it. Tomorrow.

chipw

  • Guest
Re: Listing specific members in php artical
« Reply #31 on: October 12, 2008, 05:19:11 PM »
ok, thank you very much.  gotta hit the road myself.  not making any money if the tires aren't turning.

chipw

  • Guest
Re: Listing specific members in php artical
« Reply #32 on: October 20, 2008, 11:40:45 PM »
I'm thinking there might not be a way to fix the issue.  However, I made another discovery.  If there are no members listed for a particular county, that county page does not error.  It's acts just fine.

I've added a couple more fields and revised the code a tiny bit by removing the second if/else statement.  I'm posting here so that you can see it with the new information and for safe keeping for me.

Thank you very much for all that you have done.  I can't express how much I really appreciate the help you have given me.

Code: [Select]
global $db_prefix;

// Find out who has businesses in Benton County

$request = db_query("
    SELECT ID_MEMBER
    FROM {$db_prefix}themes
    WHERE value = 'Benton County'
    AND (variable = 'CP4' OR variable = 'CP7' OR variable = 'CP8')
    ORDER BY ID_MEMBER", __FILE__, __LINE__);

if(db_affected_rows() > 0)


// create an array and to use that as part of a second query.

  while ($row = mysql_fetch_assoc($request))
    $members[] = $row['ID_MEMBER'];

// make it all into one bit of text that we can put into a query.

  $member_string = implode(" OR ID_MEMBER=",$members);

//here is the membergroup code
  $request = db_query("
      SELECT ID_MEMBER, ID_GROUP, additionalGroups
      FROM {$db_prefix}members
      WHERE ID_MEMBER=" . $member_string . "
      ORDER BY ID_MEMBER", __FILE__, __LINE__);



// Do this all a second time, this time filtering out the ones we don't want

    $members = array();

    $group = 10; // Change this to the group you're interested in

    while ($row = mysql_fetch_assoc($request)) {
      $add_groups = explode(',',$row['additionalGroups']);
      if ($row['ID_GROUP'] == $group || in_array($group,$add_groups))
        $members[] = $row['ID_MEMBER'];
    }

// make it all into one bit of text again that we can put into a query.

    $member_string = implode(" OR ID_MEMBER=",$members);

//and that is the end of the membergroup code

// Create a query to get all the information for those people
// The field for the phone would have to be included as well

    $request = db_query("
        SELECT ID_MEMBER, value, variable
        FROM {$db_prefix}themes
        WHERE ID_MEMBER=" . $member_string . "
        ORDER BY ID_MEMBER", __FILE__, __LINE__);

// put this into an array that you can print out

    while ($row = mysql_fetch_assoc($request)) {
      $m = $row['ID_MEMBER'];
      $v = $row['variable'];
      $info[$m][$v] = $row['value'];
    }
    mysql_free_result($request);

// print out the table and the column headings
    echo '<div align="center">';
    echo ' <table border="1" width="90%" cellspacing="4" cellpadding="3">';
    echo ' <tr>';
    echo ' <td colspan="5"><b><font size="4"><center>Benton County</center></b></font></td>';
    echo ' </tr>';
    echo ' <tr>';
    echo ' <td width="25%"><b>Business Name</b></td>';
    echo ' <td width="25%"><b>Address</b></td>';
    echo ' <td width="20%"><b>City</b></td>';
    echo ' <td width="10%"><b>State</b></td>';
    echo ' <td width="20%"><b>Phone</b></td>';
    echo ' </tr>';

// print out the individual information

    foreach ($members as $member) {

      echo ' <tr>';
      echo ' <td><a href="' . $scripturl . '?action=profile;u=' . $member . '">' . $info[$member]['CP1'] . '</a></td>';
      echo ' <td>' . $info[$member]['CP2'] . '</td>';
      echo ' <td>' . $info[$member]['CP3'] . '</td>';
      echo ' <td>' . $info[$member]['CP5'] . '</td>';
      echo ' <td>' . $info[$member]['CP6'] . '</td>';  // Use the field for the phone here
      echo ' </tr>';
    }
    echo ' </table>';
    echo '</div>';
}
else
echo '<center><b>There are no bondsmen listed in Benton County</b></center>';

JPDeni

  • Guest
Re: Listing specific members in php artical
« Reply #33 on: October 22, 2008, 10:34:15 AM »
I'm glad that you figured it out. I couldn't get it.