Can anyone see the error in this bit of code?
Posted: Fri May 20, 2011 1:33 pm
This code is not displaying as i'm expecting, namely the state field which is displaying the state id and not the actual text of that state - the table references are correct and i have tried all sorts of ways of tinkering with the text, but always the id is dispalyed, i.e "65, United States" is whats showing, when I want "Arizona, United States"
Can anyone see where the problem is here. The country is coming out just fine, so am very confused.
I'd be forever grateful and slightly less grey-er , thank you
Can anyone see where the problem is here. The country is coming out just fine, so am very confused.
I'd be forever grateful and slightly less grey-er , thank you
Code: Select all
//searchBySpec
function searchBySpec($option){
global $mainframe;
$user =& JFactory::getUser();
$id = (int)JRequest::getVar('id', 0, 'get', 'string');
if(empty($id))
{
$return = JRoute::_('index.php?option=com_tpjobs');
$mainframe->redirect($return);
return;
}
// Initialize variables
$db = & JFactory::getDBO();
//for header title
$query = "select a.id,specialization,category ".
" from #__tpjobs_job_spec a ".
" left join #__tpjobs_job_categ b".
" ON a.id_category = b.id".
" where a.id = ".$db->quote( $id );
$db->setQuery($query);
$categ = $db->loadObjectList();
$spec = (!empty($categ[0])) ? $categ[0] : null;
$keyword="";
$where ="where a.job_title like '%".$keyword."%'";
$where .=" and id_job_spec =".$db->quote( $id )." ";
$now = date('d-m-Y H:i:s', time() + ( $mainframe->getCfg('offset') * 60 * 60 ) );
$where .= "and a.is_active='y' and expire_date > '".$now."' and expire_date <> '0000-00-00 00:00:00'";
$limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
$limitstart = JRequest::getVar('limitstart',0,'','int');
$query = "SELECT COUNT(*)".
" from #__tpjobs_job a".
" left join #__tpjobs_country b".
" ON a.id_country = b.country".
" left join #__tpjobs_employer c".
" ON a.employer_id = c.user_id".
" left join #__tpjobs_comp_type d".
" ON c.id_comp_type = d.id ".$where.
" LEFT JOIN #__tpjobs_state e".
" ON a.state = e.id".
" ORDER BY a.publish_date DESC";
$db->setQuery( $query );
$total = $db->loadResult();
jimport('joomla.html.pagination');
$pageNav = new JPagination( $total, $limitstart, $limit );
$query ="select a.*,country,comp_name,comp_type,state ".
" from #__tpjobs_job a".
" left join #__tpjobs_country b".
" ON a.id_country = b.id".
" left join #__tpjobs_employer c".
" ON a.employer_id = c.user_id".
" left join #__tpjobs_comp_type d".
" ON c.id_comp_type = d.id ".$where.
" LEFT JOIN #__tpjobs_state e".
" ON a.state = e.state".
" ORDER BY a.publish_date DESC";
$db->setQuery( $query, $pageNav->limitstart, $pageNav->limit );
$rows = $db->loadObjectList();
HTML_front_tpjobs::searchBySpec($rows,$spec,$pageNav,$option);
}