I just typed this code up from scratch and, as I am not perfect with php syntax yet, I KNEW I was going to have some errors.. Can you tell me if anything is wrong with this??
First of all, I am working with Joomla 1.5 and I have created a new module.
"helper.php" contains the following class and function:
Code: Select all
class modComHelper
{
function getComData($params, $user)
{
$db =& JFactory::getDBO();
$userid = $user->get('id');
$query = "SELECT * FROM `ext_usertable` WHERE `refid` = '".$userid."'";
$db->setQuery($query);
$data['totalref'] = mysql_num_rows($db->query()); // This line counts the number of rows that contain instructors id as refid
$query = "SELECT `totalmade` FROM `ext_usertable` WHERE `id` = '".$userid."'";
$db->setQuery($query);
$totalmade = mysql_fetch_array($db->query());
$data['totalmade'] = $totalmade['totalmade'];
$query = "SELECT `totalcol` FROM `ext_usertable` WHERE `id` = '".$userid."'";
$db->setQuery($query);
$totalcol = mysql_fetch_array($db->query());
$data['totalcol'] = $totalcol['totalcol'];
$query = "SELECT `ppemail` FROM `ext_usertable` WHERE `id` = '".$userid."'";
$db->setQuery($query);
$ppemail = mysql_fetch_array($db->query());
$data['ppemail'] = $ppemail['ppemail'];
$query = "SELECT `accountbal` FROM `ext_usertable` WHERE `id` = '".$userid."'";
$db->setQuery($query);
$accountbal = mysql_fetch_array($db->query());
$data['accountbal'] = $accountbal['accountbal'];
return $data;
}
}
Code: Select all
require_once( dirname(__FILE__).DS.'helper.php' );
require( JModuleHelper::getLayoutPath( 'mod_mynewmodule' ) );
$user =& JFactory::getUser();
$comdata = modComHelper::getComData($params, $user);
Code: Select all
<?php echo $comdata['totalref']; ?>
Is there anything that stands out as being a problem?? I have checked the php manual for all of my code and I am pretty sure this is the proper way to do this. However, my echo statement echos nothing...