barryflood22 Posted October 23, 2012 Share Posted October 23, 2012 (edited) The below is script is part of a script which echo's a list of information with links from a database, it counts how many rows there are and displays the number beside it. would anyone be able to edit it so that if the row count = 0, then it should not display any heading for that row? <?php /** * @package RAM_ListSectors * @version 1.6.0 Stable, June 2012 */ class mod_RAM_ListSectorsHelper { // // get list of sectors from Recruitment Agency Manager // function getSectorList($no_to_display) { global $msg; $sectors = array(); //get the database configuration settings $conf =& JFactory::getConfig(); $dbprefix = $conf->getValue('config.dbprefix'); // get a handle for the std joomla DB connection (only so we can get data already translated by Joomfish!) $db =& JFactory::getDBO(); $query="SELECT * FROM ".$dbprefix."RAM_Sectors ORDER BY display_order, `desc` ASC limit 0, $no_to_display "; // $msg = "SQL: $query<br />\n"; $db->setQuery( $query ); // for Joomfish! $sth = $db->loadAssocList(); // for Joomfish! $num_rows = count($sth); // records found? if ($num_rows>0) { // yes $rownum=0; // yes while ($row=$sth[$rownum]) { $sectors[] = $row; // add the sector details to the array $rownum++; // go to the next record } } else { // no, return error message $msg = JText::_('RAM_LSM_NOSECTORS'); } // eof check for records found return $sectors; // return any sectors found } // end function getSectorList // // Get the no. of jobs for a specified sector // function getJobs($sector) { //get the database configuration settings $conf =& JFactory::getConfig(); $dbprefix = $conf->getValue('config.dbprefix'); // get a handle for the std joomla DB connection (only so we can get data already translated by Joomfish!) $db =& JFactory::getDBO(); $query="select count(*) from ".$dbprefix."RAM_jobs where `sector` = '$sector' and jobfilled='n' AND `approved`='y' and published='y' "; $db->setQuery( $query ); $sth = $db->loadAssocList(); $row=$sth[0]; $num_rows=$row['count(*)']; return $num_rows; } // end function getJobs } // eof class ?> Edited October 23, 2012 by barryflood22 Quote Link to comment https://forums.phpfreaks.com/topic/269812-can-someone-take-a-look/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.