Rewind through an array of elements in jquery
<p>Heres a simple script im using to go through an array displaying a set of html boxes. The initial function echoes a load of elements from a mysql database via php which is then put into the jquery array. </p>

<p>The next3 function works perfectly but for the life of me I cant rewind it to the last three.</p>

<p>Can any one help...</p>

<pre><code>function createTicker(){
 tickerItems = new Array();
 &lt;?php
 for($i = 0; ($rs=mysql_fetch_array($detail4conferences)); $i++) {

  $confid = '&lt;a href=\"../'.$rs['confid'].'\" class=\"forthcomingBox\"&gt;';

  if(!empty($rs['strapline'])){
   $strapline = '&lt;span class=\"prefixPages\"&gt;'.$rs['strapline'].'&lt;/span&gt;&lt;br /&gt;';
  } else {
   $strapline = '';
  }

  $title = '&lt;span class=\"hpTitle\"&gt;'.$rs['title'].'&lt;/span&gt;&lt;br/&gt;';

  if(!empty($rs['subtitle'])){
  $subtitle = '&lt;span class=\"subtitlePages\"&gt;'.$rs['subtitle'].'&lt;/span&gt;&lt;br /&gt;';
  } else {
   $subtitle = '';
  }

  $dateline = '&lt;span class=\"dateandlocationPages\"&gt;'.$rs['dateline'].'&lt;/span&gt;&lt;/a&gt;';

  echo "tickerItems[$i] = '$confid$strapline$title$subtitle$dateline';";
  }
 ?&gt;
 i = 0;
 tickerIt();
    }

    function next3(){
 if(i &gt;= tickerItems.length){
  i = 0;
 } 

 $('#tickerHolder').fadeOut(300, function(){
  $('#ticker1').html(tickerItems[i]);
  $('#ticker2').html(tickerItems[i+1]);
  $('#ticker3').html(tickerItems[i+2]);
  $('#tickerHolder').fadeIn("slow");
  i = i + 2;
  i++;
 });
    }
</code></pre>

<p>I have no idea what to do below - nothing seems to land me on the correct last three no matter what iteration I try...</p>

<pre><code>function prev3(){
 if(i &gt;= tickerItems.length){
  i = 0;
 }

 $('#tickerHolder').fadeOut(300, function(){
  $('#ticker1').html(tickerItems[i-4]);
  $('#ticker2').html(tickerItems[i-5]);
  $('#ticker3').html(tickerItems[i-6]);
  $('#tickerHolder').fadeIn("slow");
  i--;
 });
    }
</code></pre>
