title: So specific, adding a image of the artist to the table view of recent songs in a joomla component
body: <p>I want to have the image of the artist (song artist) available in the viewing of the recent songs. 
  here are the php files and the tables of the database i guess you might need when answering:
  (I'd be happy if someone would teach me so fast how to use query commands for selecting a data like this in a crossed usage of tables not just one row of the tables. if no plz change the code so it views artist picture)</p>
  
  <p><strong>Here is the helper php code</strong></p>
  
  <pre><code>&lt;?php
  
  // no direct access
  defined('_JEXEC') or die('Restricted access');
  
  class modMusColRecentlyAddedSongsHelper
  {
  
  
  function getSongs(&amp;$params)
  {
      global $mainframe;
      $_db    = &amp; JFactory::getDBO();
      $model      = modMusColRecentlyAddedSongsHelper::getModel();
  
          $limit = $params-&gt;get( 'n_songs', 5 );
  
          if($params-&gt;get( 'artist_id' )) $where_clause[] = " s.artist_id = " . $params-&gt;get( 'artist_id' ) . " " ;
  
          if ($params-&gt;get( 'genre_id' )) {
              $genre_id = $params-&gt;get( 'genre_id' );
              $model-&gt;getDescendantsId($genre_id); 
              $descendants = $model-&gt;descendantsId;
              $descendants[] = $genre_id ;
              $genre_clause = ' ( s.genre_id = ' . implode(' OR s.genre_id = ',$descendants) . ' ) ';
              $where_clause[] = $genre_clause;
          }
  
  
              //$where_clause[] = ' ra.type = "song" ';
              $where_clause = (count($where_clause) ? ' WHERE '.implode(' AND ', $where_clause) : '');
  
              $query =    ' SELECT s.*, ar.artist_name,al.name as album_name, AVG(ra.points) as points FROM #__muscol_songs as s '.
                          ' LEFT JOIN #__muscol_albums as al ON al.id = s.album_id '.
                          ' LEFT JOIN #__muscol_artists as ar ON ar.id = s.artist_id '.
                          ' LEFT JOIN #__muscol_ratings as ra ON ra.album_id = s.id AND ra.type = "song" '.
                          $where_clause .
                          ' GROUP BY s.id ' .
                          ' ORDER BY s.added DESC '.
                          ' LIMIT '. $limit;
  
                          //echo $query;die;
  
  
          $_db-&gt;setQuery( $query );
          $recent_songs = $_db-&gt;loadObjectList();
  
          //print_r($query);die;
  
          return $recent_songs;
  
  }
  
  function getModel()
  {
      if (!class_exists( 'ArtistsModelSearch' ))
      {
          // Build the path to the model based upon a supplied base path
          $path = JPATH_SITE.DS.'components'.DS.'com_muscol'.DS.'models'.DS.'search.php';
          $false = false;
  
          // If the model file exists include it and try to instantiate the object
          if (file_exists( $path )) {
              require_once( $path );
              if (!class_exists( 'ArtistsModelSearch' )) {
                  JError::raiseWarning( 0, 'Model class ArtistsModelSearch not found in file.' );
                  return $false;
              }
          } else {
              JError::raiseWarning( 0, 'Model ArtistsModelSearch not supported. File not found.' );
              return $false;
          }
      }
  
      $model = new ArtistsModelSearch();
  
      return $model;
  }
  
  }
  </code></pre>
  
  <p><strong>Here is the default.php code</strong> </p>
  
  <pre><code>&lt;?php // no direct access
  defined('_JEXEC') or die('Restricted access'); ?&gt;
  &lt;?php
  if($params-&gt;get( 'Itemid' )) $itemid = "&amp;Itemid=".$params-&gt;get( 'Itemid' );
     else $itemid = "";
     $document =&amp; JFactory::getDocument();
     $document-&gt;addStyleSheet(JURI::base(true).'/modules/mod_muscol_recently_added_songs/tmpl/recently_added_songs.css');
  ?&gt;
  
   &lt;div class='recently_added_songs'&gt;
   &lt;table border='0' cellpadding='0' cellspacing='0' width="100%"&gt;
   &lt;thead&gt;
   &lt;tr&gt;
    &lt;th&gt; &lt;?php echo JText::_( 'آهنگ' ); ?&gt; &lt;/th&gt;
     &lt;? if($params-&gt;get('show_album')){ ?&gt;&lt;th&gt; &lt;?php echo JText::_( 'آلبوم' ); ?&gt; &lt;/th&gt;&lt;? } ?&gt;
    &lt;? if($params-&gt;get('show_artist')){ ?&gt;&lt;th&gt; &lt;?php echo JText::_( 'خواننده' ); ?&gt; &lt;/th&gt;&lt;? } ?&gt;
    &lt;? if($params-&gt;get('show_rating')){ ?&gt;&lt;th&gt; &lt;?php echo JText::_( 'امتياز' ); ?&gt; &lt;/th&gt;&lt;? } ?&gt;
  &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;?php
   $n = 0;
    for ($j=0, $m=count( $songs ); $j &lt; $m; $j++) {
   $song = $songs[$j];
  $link= JRoute::_( 'index.php?option=com_muscol&amp;view=song&amp;id='. $song-&gt;id . $itemid);
  $link_album= JRoute::_( 'index.php?option=com_muscol&amp;view=album&amp;id='. $song-&gt;album_id . $itemid);
  $link_artist= JRoute::_( 'index.php?option=com_muscol&amp;view=artist&amp;id='. $song-&gt;artist_id . $itemid);
  
  //$image = MusColHelper::createThumbnail($album-&gt;image, $album-&gt;name, $params-&gt;get('default_width'), $image_attr);
  ?&gt;
   &lt;tr class="tr_recent_songs &lt;?php echo "row$n"; ?&gt;"&gt;
    &lt;td&gt;&lt;a href="&lt;?php echo $link; ?&gt;"&gt;&lt;?php echo $song-&gt;name; ?&gt;&lt;/a&gt;&lt;/td&gt;
    &lt;? if($params-&gt;get('show_album')){ ?&gt;&lt;td&gt;&lt;a href="&lt;?php echo $link_album; ?&gt;"&gt;&lt;?php echo $song-&gt;album_name; ?&gt;&lt;/a&gt;&lt;/td&gt;&lt;? } ?&gt;
    &lt;? if($params-&gt;get('show_artist')){ ?&gt;&lt;td&gt;&lt;a href="&lt;?php echo $link_artist; ?&gt;"&gt;&lt;?php echo $song-&gt;artist_name; ?&gt;&lt;/a&gt;&lt;/td&gt;&lt;? } ?&gt;
    &lt;? if($params-&gt;get('show_rating')){ ?&gt;&lt;td&gt;&lt;?php echo MusColHelper::show_stars($song-&gt;points,false,false,false,true);?&gt;&lt;/td&gt;&lt;? } ?&gt;
  &lt;/tr&gt;
  &lt;?php
  $n = 1 - $n ;
  }
  ?&gt;
   &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>songs</strong> table in the database (name of the table is songs)</p>
  
  <pre><code>id  album_id  num  disc_num  length  name  lyrics  artist_id  composer_id  filename  extension  review  songwriters  chords  genre_id  hits  buy_link  video  position  downloaded  user_id
  </code></pre>
  
  <p><strong>artists</strong> table in the database  (the artist picture should be read from picture column)</p>
  
  <pre><code>id artist_name  image  review  letter  class_name  related  keywords  added  hits  country  picture  user_id  metakeywords  metadescription  city  years_active  url  genre_id
  </code></pre>