I use the following code: fetchAll
and for($mich=0;$mich<10;$mich++)
.
Is this the best way?
Is there a better way, either to optimize or replace this code?
<?php
include("cache/phpfastcache.php");
phpFastCache::setup("storage","auto");
$cache = phpFastCache();
$products = $cache->get("product_page");
if($products == null) {
$akhbarkotah1 = $conn->prepare("SELECT text,time FROM small WHERE active='0' ORDER BY time DESC LIMIT 10");
$akhbarkotah1->execute();
$products = $akhbarkotah1->fetchAll();
$cache->set("product_page", $products,30);
}
for($mich=0;$mich<10;$mich++){
$text1 =$products[$mich][0];
$time1 =$products[$mich][1];
?>
<a class="lastnews">
<div id="lastnews_title" class="YekanBlack10" style="width:585px;">
<div><?php echo $text1; ?></div>
<div class="YekanRed10" style="text-align:left">
<?php echo timeTonow($time1); ?>
</div>
<div style="border-bottom:2px solid #7c0000;height:5px;"></div>
</div>
</a>
<?php
}
?>