Hi folks, really hope someone can help me out here. I’m basically displaying results from database using mysql and i would love to introduce some pagination. Currently i use a loop to show only 12 lines but i’m really not sure how to add pagination to show 12 lines per page. I’ll post my code so far and maybe somebody can point me in the right direction.
[code]
<?php include 'config.php'; ?> <?php // Connect to the database $query="SELECT * FROM vehicles"; $result=mysql_query($query); $num=mysql_numrows($result); $i=1; while ($i<=12) { $f1=mysql_result($result,$i,"imagerefs"); $f2=mysql_result($result,$i,"make"); $f3=mysql_result($result,$i,"price"); $f4=mysql_result($result,$i,"varianttext"); $f5=mysql_result($result,$i,"mileage"); $f6=mysql_result($result,$i,"year"); $f7=mysql_result($result,$i,"vehicle_id"); $f8=mysql_result($result,$i,"engine"); $f9=mysql_result($result,$i,"title"); $f10=mysql_result($result,$i,"model"); $f11=mysql_result($result,$i,"reg"); $f12=mysql_result($result,$i,"bodystyle"); $f13=mysql_result($result,$i,"transmission"); $f14=mysql_result($result,$i,"fueltype"); $f15=mysql_result($result,$i,"colour"); $f16=mysql_result($result,$i,"cap_features"); $f17=mysql_result($result,$i,"seller_email"); ?> <article>
<a href="one-products.php?vehicle_id=<?php echo $f7; ?>"class="single-image picture">
<img src="<?php $parts = explode(',', $f1); echo $parts[0]; ?>">
</a>
<div class="detailed">
<h6>
<a href="one-products.php?vehicle_id=<?php echo $f7; ?>"class="title-item"><?php echo $f9; ?></a>
</h6>
<span class="price">£<?php echo $f3; ?></span>
<div class="clear"></div>
<ul class="list-entry">
<li><b>Engine:</b><span><?php echo $f8; ?></span></li>
<li><b>Mileage:</b><span><?php echo $f5; ?></span></li>
<li><b>Year:</b><span><?php echo $f6; ?></span></li>
<li><b>Location:</b><span><?php echo strstr($f17, '@', true); ?></span></li>
<li><b>Reference:</b><span><?php echo $f7; ?></span></li>
</ul><!--/ .list-entry-->
<label class="compare"><input type="checkbox" />Compare</label>
<a href="one-products.php?vehicle_id=<?php echo $f7; ?>"class="button orange">Details »</a>
</div><!--/ .detailed-->
</article>
<?php
$i++;
}
?>[/code]
Apologies for the mashup of code, but this is as far as i have got.
Thanks again for any help !