List Clubs
Posted
#6185
(In Topic #1510)

Standard member

This approach directly accesses the database. After this code is uploaded to your site, then you can add the mini block in the left or right or center panel. My code is usually not very good quality, but it works, so improvements are welcome.
<style> tr:nth-child(even) { background-color: #c2d1e5; } tr:nth-child(odd) { background-color: white; } </style> <?php $rows = $GLOBALS['SITE_DB']->query_select('f_groups', // Use this table array('id','g_name','g_group_leader'), // Get these fields array('g_is_private_club' => 1)); // WHERE this if (count($rows) == 0) { echo "<p>No Clubs found.</p>"; return; } echo "<table><tr><th>Club name</th><th>Owner</th><th>Link</th></tr>"; foreach ($rows as $row) { $club_owner = $GLOBALS['FORUM_DRIVER']->get_username($row["g_group_leader"]); $link = "somewebsite/index.php?page=groups&type=view&id=" . str_replace(" ", "-", trim($row["g_name"])); echo "<tr><td>" . $row["g_name"] . "</td><td>" . $club_owner . "</td><td><a href='" . $link . "'>" . "Join" . "</a></td></tr>"; } echo "</table>"; ?>
1 guest and 0 members have just viewed this.