I am not getting any of the Items for the user

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"
		. "\
 LEFT JOIN jos_pf_task_users AS tu ON tu.task_id = t.id"
		. "\
 LEFT JOIN jos_users AS u ON u.id = tu.user_id"
		. "\
 LEFT JOIN jos_pf_projects AS p ON p.id = t.project"
		. "\
 LEFT JOIN jos_pf_milestones AS m ON m.id = t.milestone"
		. "\
 WHERE p.id = $id"
		. "\
 AND tu.user_id = $id"
		. "\
 GROUP BY t.id"
		. "\
 ORDER BY t.cdate ASC"
           . "\
 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);
    }
}
?>

You commented out the code that populates $rows and set it to an empty array

    $rows = array();

So count($rows) == 0, and when that happens, you told it to print that message.

Changed it to :


    // Load tasks
	$query = "SELECT t.*, u.name, p.title project_name, p.id pid, m.title ms_title FROM jos_pf_tasks AS t"
		. "\
 LEFT JOIN jos_pf_task_users AS tu ON tu.task_id = t.id"
		. "\
 LEFT JOIN jos_users AS u ON u.id = tu.user_id"
		. "\
 LEFT JOIN jos_pf_projects AS p ON p.id = t.project"
		. "\
 LEFT JOIN jos_pf_milestones AS m ON m.id = t.milestone"
		. "\
 WHERE p.id = t.project"
		. "\
 AND tu.user_id = $userid"
		. "\
 GROUP BY t.id"
		. "\
 ORDER BY t.cdate ASC"
           . "\
 LIMIT $limit";
    	   $db->setQuery($query);
    	   $rows = $db->loadObjectList();
	echo $rows;
	
    $rows = array();
    
    if($userid) {

Still nothing prints out, RUN SQL query with set values and it returns data…

Have you tried ‘echo $query’ to see whether it contains the values you expect? For example, where are $userid and $limit supposed to come from? You don’t define those variables in the code snippets you’ve pasted.

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.