TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 18, 2024, 06:50:34 PM

Login with username, password and session length
Members
  • Total Members: 3,886
  • Latest: Grendor
Stats
  • Total Posts: 195,189
  • Total Topics: 21,220
  • Online today: 112
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 50
  • Total: 50

Listing specific members in php artical

Started by chipw, September 20, 2008, 11:06:36 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JPDeni

I'll see if I can add all this to my test site and work on it. Tomorrow.

chipw

ok, thank you very much.  gotta hit the road myself.  not making any money if the tires aren't turning.

chipw

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.


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

I'm glad that you figured it out. I couldn't get it.