danjapro Posted July 13, 2011 Share Posted July 13, 2011 Here is my code, All I am trying to do it eco and print out all the task or a limit# of tasks that is assigned to the user page being viewed: However, in return it just prints out this html tag for every user: <div class="pf_info">'.PFformat::Lang('PFL_NO_TASKS').'</div> This states that theya re no task found assigned to that user, what am I missing here..some of the users should show tasks listed...... <?php $id = (int) JRequest::GetVar('id'); if($id) { // Load objects $db = PFdatabase::GetInstance(); //$user = PFuser::GetInstance(); $user =& JFactory::getUser(); $config = PFconfig::GetInstance(); // Load config params // Load tasks $query = "SELECT t.*, u.name, p.title project_name, p.id pid, m.title ms_title FROM #__pf_tasks AS t" . "\n LEFT JOIN jos_pf_task_users AS tu ON tu.task_id = t.id" . "\n LEFT JOIN jos_users AS u ON u.id = tu.user_id" . "\n LEFT JOIN jos_pf_projects AS p ON p.id = t.project" . "\n LEFT JOIN jos_pf_milestones AS m ON m.id = t.milestone" . "\n WHERE p.id = $id" . "\n AND tu.user_id = $id" . "\n GROUP BY t.id" . "\n ORDER BY t.cdate ASC" . "\n LIMIT $limit"; $db->setQuery($query); //$rows = $db->loadObjectList(); echo $rows; $rows = array(); if($user->id) { $html = ' <table class="pf_table adminlist" width="100%" cellpadding="0" cellspacing="0"> <thead> <tr> <th align="center">#</th> <th width="50%">'.PFformat::Lang('TITLE').'</th> <th width="25%">'.PFformat::Lang('ASSIGNED_TO').'</th> <th width="10%">'.PFformat::Lang('PRIORITY').'</th> <th width="10%">'.PFformat::Lang('DEADLINE').'</th> <th width="5%">'.PFformat::Lang('PROGRESS').'</th> </tr> </thead> <tbody>'; $k = 0; foreach ($rows AS $i => $row) { JFilterOutput::objectHTMLSafe($row); $p_edit_s = ""; $p_edit_e = ""; $t_edit_s = ""; $t_edit_e = ""; $deadline = PFformat::Lang('NOT_SET'); if($row->edate) $deadline = PFformat::ToDate($row->edate); if($tlink == 1) { $t_edit_s = "<a href='".PFformat::Link("section=tasks&task=display_details&id=".$row->id)."'>"; $t_edit_e = "</a>"; } $html .= ' <tr class="pf_row'.$k.' row'.$k.' sectiontableentry'.($k+1).'"> <td>'.($i + 1).'</td> <td>'.$t_edit_s.$row->title.$t_edit_e.'</td> <td>'.$row->name.'</td> <td>'.$priority.'</td> <td>'.$deadline.'</td> <td>'.$row->progress.'%</td> </tr>'; $k = 1 - $k; } if(!count($rows)) { $html .= ' <tr class="pf_row0"> <td colspan="7" align="center" style="text-align:center"><div class="pf_info">'.PFformat::Lang('PFL_NO_TASKS').'</div></td> </tr>'; } $html .= '</tbody></table>'; echo $html; unset($html, $rows); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/241862-help-to-return-usre-tasks-listing-from-query/ Share on other sites More sharing options...
jcbones Posted July 13, 2011 Share Posted July 13, 2011 Have you run your query directly in the database, to make sure it performs as expected? Quote Link to comment https://forums.phpfreaks.com/topic/241862-help-to-return-usre-tasks-listing-from-query/#findComment-1242081 Share on other sites More sharing options...
danjapro Posted July 13, 2011 Author Share Posted July 13, 2011 I have here is my sql update and still no results. // Load tasks $query = "SELECT t.*, u.name, p.title project_name, p.id pid, m.title ms_title FROM #__pf_tasks AS t" . "\n LEFT JOIN jos_pf_task_users AS tu ON tu.task_id = t.id" . "\n LEFT JOIN jos_users AS u ON u.id = tu.user_id" . "\n LEFT JOIN jos_pf_projects AS p ON p.id = t.project" . "\n LEFT JOIN jos_pf_milestones AS m ON m.id = t.milestone" . "\n WHERE p.id = $id" //. "\n AND tu.user_id = $userid" . "\n GROUP BY t.id" . "\n ORDER BY t.cdate ASC" . "\n LIMIT $limit"; $db->setQuery($query); $rows = $db->loadObjectList(); echo $rows; I can't see issue anywhere....SQL help Quote Link to comment https://forums.phpfreaks.com/topic/241862-help-to-return-usre-tasks-listing-from-query/#findComment-1242122 Share on other sites More sharing options...
jcbones Posted July 13, 2011 Share Posted July 13, 2011 So, let me get this straight, because I'm not sure you understood my question. You typed that query into the database console, and it returned the rows you expected. If that is the case, then you will have to look into your db class to see where the error is. Perhaps your database class has an error/de-bug function. I would run that to see if there is an error. Quote Link to comment https://forums.phpfreaks.com/topic/241862-help-to-return-usre-tasks-listing-from-query/#findComment-1242464 Share on other sites More sharing options...
danjapro Posted July 18, 2011 Author Share Posted July 18, 2011 Respect, I was able to produce the output needed. Thank you all very much changed line 37: $rows = array(); to if(!is_array($rows)) $rows = array(); Worked produced the exact need out put. Quote Link to comment https://forums.phpfreaks.com/topic/241862-help-to-return-usre-tasks-listing-from-query/#findComment-1244256 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.