Jump to content

Loops With Smarty


Danny2k5

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.