Displaying unique class for one entry from an array of entries
<p>I have this query:</p>

<pre><code>$top4=$wpdb-&gt;get_results('SELECT post_title, post_name from `'.$wpdb-&gt;prefix.'pageviews`       
INNER JOIN `'.$wpdb-&gt;prefix.'posts` ON `postid`=`ID` 
ORDER BY `pageviews` DESC 
LIMIT 4;', ARRAY_A);
</code></pre>

<p>How can I display the results of it in this format using <code>foreach</code>:</p>

<pre><code> echo '&lt;li class="trendingPost" &lt;a href=mysite.com/'.$post_name.'&gt;'$post_title'&lt;/a&gt;&lt;li&gt;'
</code></pre>

<p>The last one having li class="trendingPost last"</p>