Add a php loop to a series of divs with incremental class names -
i'm building html page i'd add php loop to.
at present code looks this:
<?php $i = 0; ?> <div class="element-item <?php echo mysql_result($value, $i);?>">...</div> <?php $i = $i+1; ?> <div class="element-item <?php echo mysql_result($value, $i);?>">...</div> <?php $i = $i+1; ?> <div class="element-item <?php echo mysql_result($value, $i);?>">...</div>
however every div same, apart ($value, $i) $i rising in value 1 each time, i'd way of declaring upfront loop contain x amount of divs (in case 3 in reality on 100) , each time repeats $i rises +1
all appreciated...
using while loops may solve problem... make sure $query = mysql_query("")
while($row = mysql_fetch_assoc($query)){ $value = $row["columnname"]; $i++; echo "<div>your content here</div>" }
please use prepared statements (http://php.net/manual/en/pdo.prepared-statements.php). mysql_* deprecated
Comments
Post a Comment