Hi
I am working on a website that uses smarty tags and to be honest am really stuck as don't use smarty often
The site is http://irhwebsites.com/sites/zacs-car-site/index.php
I want to have instead of featured listings have recently added and think I got the listings displayed but it only displays listings with images where as I would like it to display listings with and without images and also have it display random listings not just one
below are the links to pastebin with the coding for that section
functions.php
function getRandomImage()
{
global $use_listing_approval;
$limit = 3;
$approved = '';
if ($use_listing_approval) {
if (!isset($_SESSION["admin"])) {
if (isset($_SESSION["seller"])) {
$approved = "";
} else {
$approved = "listings.approved = 1 AND listimages.approved = 1 AND ";
}
}
}
//$sql = "SELECT * FROM listimages, listings WHERE $approved listings.id = listimages.listingid AND listings.sold !=1 AND listimages.mainimage = 1 ORDER BY RAND() LIMIT $limit";
$sql = "SELECT * FROM listimages, listings WHERE $approved listings.id = listimages.listingid AND listings.sold !=1 AND listimages.mainimage = 1 ORDER BY added_on DESC LIMIT $limit";
$res = sqlQuery($sql); if(sqlErrorReturn()) sqlDebug(__FILE__,__LINE__,sqlErrorReturn());
$c=0;
while ($a_row = sqlFetchArray($res)) {
$records[$c]["ad_title"] = $a_row["ad_title"];
$records[$c]["make"] = $a_row["make"];
$records[$c]["model"] = $a_row["model"];
$records[$c]["listingid"] = $a_row["listingid"];
$records[$c]["imagepath"] = $a_row["imagepath"];
$records[$c]["imagethumbpath"] = $a_row["imagethumbpath"];
//Price_eingef�gt_09_02_09
$records[$c]["price"] = $a_row["price"];
++$c;
}
if (isset($records))
return $records;
return false;
}
index.tpl file
{if $records}
<div class="smallrightlist">
<h2 class="subhead">{$smarty.const.INDEX_FEATURED}</h2>
{foreach item="image" from=$records}
<p>
{if $use_fancy_urls}
<a href="listings/view/{$image.make|strip:"-"}/{$image.model|strip:"-"}/{$image.listingid}/">
<img src="{$image.imagethumbpath}" title="{$smarty.const.IMAGE} {counter}" alt="{$smarty.const.IMAGE} {counter}" /></a>
{else}
<a href="listings.php?make={$image.make|strip:"-"}&model={$image.model|strip:"-"}&id={$image.listingid}"><img src="{$image.imagethumbpath}" title="{$smarty.const.IMAGE} {counter}" alt="{$smarty.const.IMAGE} {counter}" /></a>
{/if}
<br />{$image.ad_title}
</p>
{/foreach}
</div>
{/if}
index.php file
//get random images for the frontpage
$smarty->assign("records",getRandomImage());
I just don't get it, please help am well stuck
Thank you
Kind regards
Ian