SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    vi
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation 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......

    Code:
    <?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);
        }
    }
    ?>

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You commented out the code that populates $rows and set it to an empty array

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

  3. #3
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    vi
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Changed it to :

    Code:
        // Load tasks
    	$query = "SELECT t.*, u.name, p.title project_name, p.id pid, m.title ms_title FROM jos_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 = t.project"
    		. "\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;
    	
        $rows = array();
        
        if($userid) {
    Still nothing prints out, RUN SQL query with set values and it returns data....

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    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.

  5. #5
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    vi
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Respect, I was able to produce the output needed. Thank you all very much changed line 37:

    Code:
    $rows = array();
    to

    Code:
    if(!is_array($rows)) $rows = array();
    Worked produced the exact need out put.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •