Jump to content

Archived

This topic is now archived and is closed to further replies.

Danny2k5

Loops With Smarty

Recommended Posts

Right my query will show "There are 4 results in the download section" after a search but underneath it says "No Results, can anyone see anything wrong with my code?

[code]$SEARCH_DOWN_ARRAY = array();

$download_query = @mysql_query("SELECT * FROM ti_downloads WHERE d_title LIKE '%$search%' OR d_small_description LIKE '%$search%' OR d_long_description LIKE '%$search%'");

$num_downloads = @mysql_num_rows($download_query);
        $dow = @mysql_fetch_array($download_query);

$SEARCH_DOWN_ARRAY[] = array(
"title" => '<a href="/index.php?action=downloads&cat=' . $catid . '&file=' . $dow["id"] . '" title="' . htmlentities($dow["d_title"]) . '">' . htmlentities($dow["d_title"]) . ' by ' . htmlentities($dow["d_creator"]) . '</a>',
"creator" => htmlentities($dow["d_creator"])
);
$smarty -> assign("NUM_DOWNLOADS", $num_downloads);
$smarty -> assign("SEARCH_DOWN_ARRAY", $SEARCH_DOWN_ARRAY);
$smarty -> assign("THE_INCLUDE", $smarty -> fetch(SROOT . "templates/search.tpl"));
}
[/code]

Then the template looks like:

[code]                                {section name=down loop=$SEARCH_DOWN_ARRAY}
                                {$SEARCH_DOWN_ARRAY[down].title}<br />
                                {sectionelse}
                                No Results
                                {/section}
[/code]

Thanks People
Dan

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.