I need a little help. I've read the documentation and I'm only getting more confused.
I need to retrieve the data from the db and add it to another view, but I'm having no luck.
I have a form that I can input information about a project, and the view where I can see the information, it's the display view that isn't editable. I also have a form that I can input sub-contractor info.
I want to pull the data from the sub-contractor table and add it to the project display view. But nothing I've tried has worked'
Heres what I have in the Front end model
Code: Select all
public function getSubcontractors()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('*');
$query->from('#__projexpm_subcontractor');
$subcons = $db->loadObjectList();
return $subcons;
}
Code: Select all
public function display($tpl = null)
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
$this->state = $this->get('State');
$this->item = $this->get('Data');
$this->params = $app->getParams('com_projexpm');
$subcons = $this->get('Subcontractors');
if (!empty($this->item))
{
$this->form = $this->get('Form');
}
Code: Select all
<tr>
<th><?php echo ('test'); ?></th>
<td><?php echo $subcons->project_num; ?></td>
</tr>
Ultimately I want a repeated table showing the sub-contractors related to a project, which I'm sure I'll need to adjust the query, and add a "foreach" statement, but so far I can't get a single variable to display.
Can someone please explain or point me in the right direction as to the what and were I put the query, and subsequent info to make this work?
Thanks