Page 1 of 1

Adding A Members Golf HDCP Block

Posted: 3. January 2010 14:40
by RobC
Hello
I am new to phpbb but am slowly learning :oops: (just started learning MySQL and PHP also so be gentle :roll: )
I am using the Board 3 portal and AeroRed
I would like to add a custom box to the portal which I have done no problem.
The problem comes with the info I want in the box...I would like to show a list of Members and their golf handicap (from the custom profile field)
This is the code I have for the .HTML:-

Code: Select all

{$C_BLOCK_H_L}Handicaps{$C_BLOCK_H_R}
<table class="tablebg" cellspacing="1" width="100%">
	<tr class="row1">
		<td>Player</td>
		<td>HDCP</td>		
<!-- BEGIN handicaplist -->
   <tr class="row1">
      <td><strong>{handicaplist.USER_NAME} : {handicaplist.HANDICAP}</strong></td>
   </tr>
<!-- END handicaplist -->
	</tr>	
</table>
{$C_BLOCK_F_L}{$C_BLOCK_F_R}
And this is the code for the .php:-

Code: Select all

<?php

//Portal Block to return username and handicap

//make sure the code is being called inside of the application itself and is not a hack attempt
        if (!defined('IN_PHPBB'))
        {
           exit;
        }

//make sure it is being run from the portal mod
        if (!defined('IN_PORTAL'))
        {
           exit;
        }
        
//select the username from the users table paired with the handicap from the profile fields table by user_id        
 $sql = 'SELECT u.username, p.handicap
		FROM ' . USERS_TABLE . ' u
		LEFT JOIN  . PROFILE_FIELD_DATA_TABLE . p
			ON u.user_id = p.user_id	
		ORDER BY u.username ASC';
//execute the query and assign the results to the $result array
$result = $db->sql_query($sql);

//loop through each item in the result set assigning each row to the row array and then read the row array and set the values in the handicaplist array for the block display from the contents of the row
foreach($result as $row)
        {
            $template->assign_block_vars('handicaplist', array(
                'USER_NAME'    => $row['username'],
                'HANDICAP'        => $row['handicap'],
            ));
        }
?>   
All I get showing in the box is "Player" and "HDCP"
After trying to work out what is going wrong(for a whole week) I am now going round in circles :(

Thanks For Any Help
Cheers RobC