title: How to add class dynamically inside a loop using PHP
body: <p>I need one help.I am displaying some data which are coming from DB but i need to set the class name dynamically in each loop iteration using PHP.I am explaining my code below.</p>
  
  <pre><code>&lt;?php
       $class=array('classname'=&gt;'pic1-caption bottom-to-top','classname'=&gt;'pic1-caption top-to-bottom','classname'=&gt;'pic1-caption left-to-right','classname'=&gt;'pic1-caption right-to-left','classname'=&gt;'pic1-caption rotate-in','classname'=&gt;'pic1-caption rotate-out','classname'=&gt;'pic1-caption open-up','classname'=&gt;'pic1-caption open-down','classname'=&gt;'pic1-caption open-left','classname'=&gt;'pic1-caption open-right','classname'=&gt;'pic1-caption come-left','classname'=&gt;'pic1-caption come-right');
       $sql=mysql_query("select * from phr_health_care where status=1  order by health_id desc");
       $key=0;
       while($row=mysql_fetch_array($sql)){
   ?&gt;
  &lt;div class="pic1"&gt;
   &lt;img src="backend/uploads/&lt;?php echo $row['image'] ?&gt;" class="pic1-image" alt="pic1"/&gt;
   &lt;span class="pic1-caption bottom-to-top"&gt; //here need to set class name dynamically.
   &lt;h1 class="pic1-title"&gt;DIABETICS&lt;/h1&gt;
   &lt;p class="newp"&gt;&lt;?php echo $row['title'] ?&gt;&lt;/p&gt;
    &lt;a href="health.html" class="detall"&gt;Go for Details&lt;/a&gt;
  &lt;/span&gt;
  </code></pre>
  
  <p></p>
  
   
  
  <p>Here All data are coming from database and i need to set class name in <code>span element</code> dynamically which are declared in <code>$class</code> variable .Here also i need once all class declared inside <code>$class</code> variable will finish while loop continuing ,again it will start from beginning  until the db value fetch has not finished.Please help me.</p>