How to make PHP loop refresh when clicking class tag -


okay have portfolio page display couple of thumbnails, , can order tags, example this:

<a href="#" title="year1" class="sort" onclick="reveal('year1');">year 1</a> 

and works fine. however, thumbnails display @ 3 on row, first 2 should have right margin, third 1 no margin. used php works fine.

if ($result=$link->query($query)) {     ($i=1; $i <= $result->num_rows; $i++) {     $row= $result->fetch_assoc();      $id = $row['number'];     $title = $row['title'];     $bgthumbnail = $row['thumbnail'];       if($i%3 == 0){                               echo "     <div class=\"thumbnail\">          <a href=\"portfoliodetail.php?id=$id\">          <div class=\"thumbnailoverview nomargin\" style=\"background: url('images/portfolio/thumbnails/$bgthumbnail'); background-position: center center;\">              <div class=\"latestworktitle\">$title</div>          </div>          </a>     </div>     ";      } else {      echo "     <div class=\"thumbnail\">         <a href=\"portfoliodetail.php?id=$id\">         <div class=\"thumbnailoverview\" style=\"background: url('images/portfolio/thumbnails/$bgthumbnail'); background-position: center center;\">             <div class=\"latestworktitle\">$title</div>         </div>         </a>     </div>     ";      }  }    $result->close(); } 

however, when click tag, margin doesn't update. when thumbnail given no margin in overview because third 1 in row, when displays first because of chosen tag, receives no margin.

of course because nothing "refreshes" or something, wondering if there "easy" way fix problem? make php loop run again or something?

you must set/remove nomargin class name via javascript:

$('.year-clicker').click(function (event) {     event.preventdefault();     var year = $(event.currenttarget).data('year');     $('.thumb').hide().removeclass('nomargin').filter('.year' + year).show();     $('.thumb:visible').each(function (i, e) {         if ((i + 1) % 3 == 0) {             $(e).addclass('nomargin');         }     });     return false; }); 

try out jsfiddle http://jsfiddle.net/xge3k/1/


Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -