Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8534415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:11:30+00:00 2026-06-11T10:11:30+00:00

I am new to smarty and I am trying to get my assigned variable

  • 0

I am new to smarty and I am trying to get my assigned variable $dropcat to work – I can print_r out this array fine.

When I use the following method nothing displays why?

{foreach  from=$dropcat item=cat}
      <select name="{$cat.id}" multiple>
        <option value="{$cat.id}">{$cat.name}</option>
      </select>
      {/foreach} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:11:31+00:00Added an answer on June 11, 2026 at 10:11 am

    your code should be something like:

    PHP

    // other stuff, instance etc
    print_r($dropcat);
    $smarty->assign('dropcat',$dropcat);
    $smarty->display('yourhtml.tpl');
    

    TPL

    <select name="category" multiple>
    {foreach from=$dropcat item='cat'}
       <option value="{$cat.id}">{$cat.name}</option>
    {/foreach}
    </select>
    

    Note foreach inside select and assign in php code.

    If still nothing appear, try to clear smarty cache, or your other project cache if any.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get Smarty 3 to work as a template engine for Symfony
i am new to smarty template and i am trying to do this. I
new to c#. I'm trying to make a simple system where I can search
I'm battling out of memory issues with my application and am trying to get
I am trying to use smarty variables inside javascript inside tpl {literal} <script language=javascript>
I am trying to use the New Methods for National Character Set Type Data
First, I'd like to thank anyone that can get me through this in advance.
I am relatively new to CMake, and I'm trying use the boost asio library
I have a url that look like this reg.php?lang=no_NO&passkey=test and im trying to get
I have problem with WPF - I'm quiet new in this smart technology. So

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.