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 6637633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:20:18+00:00 2026-05-25T23:20:18+00:00

My Sql function getLive_projects has this query – $query = SELECT p.* FROM projects

  • 0

My Sql function getLive_projects has this query –
$query = “SELECT p.* FROM projects p WHERE p.live = 1 ORDER BY client_name ASC”;
$response = $this->db->query($query)->result();

My Controller :
// get live projects
$data[‘live_projects’] = $this->projects->get_live_projects();
// load the projects with the data
$this->parser->parse(“projects.tpl”, $data);

The data in my template looks like this when I use {$live_projects|print_r}

Array
(
[0] => stdClass Object
    (
        [id] => 1
        [client_name] => client one
        [dev_url] => clientone.com
        [live_url] => clientone.com
        [version] => 1.0
        [live] => 1
    )

[1] => stdClass Object
    (
        [id] => 2
        [client_name] => client two
        [dev_url] => clienttwo.com
        [live_url] => clienttwo.com
        [version] => 3.1
        [live] => 1
    )

)

How can I output this in my template? I tried {foreach from=$live_projects item=$project} and then tried to use {$project->client_name} but that didn’t work. Should the object not be available to me when I loop over the array? Have I missed something obvious? Am I going about this in the right way? I just want to loop over the returned results and display each one as a row in my template.

I have searched the forums but was unable to find an answer that solved my issue – any help would be much appreciated. There are some example out there about using $live_projects[0]->id but how can this be incorporated into output from smarty where many items are returned in the result set.

  • 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-05-25T23:20:18+00:00Added an answer on May 25, 2026 at 11:20 pm

    You were almost there! When defining the name of your item variable, you don’t have to include the ‘$’ sign. Change your code to:

    {foreach from=$live_projects item=project}
        {$project->client_name}
    {/foreach}
    

    That should do the trick.

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

Sidebar

Related Questions

I have a sql function that includes this code: DECLARE @CodeNameString varchar(100) SELECT CodeName
I have an SQL Function with the following SQL within: SELECT StockID FROM (SELECT
I have an MS SQL function that is called with the following syntax: SELECT
I'm currently debugging an Ms SQL Function (SQL 2008). In this function, I have
I have PL/SQL function, which is programmed to sort a set of data. This
Can someone please convert this access sql function for me to work in t-sql
i'm playing around with building a sql function that will extract numbers from a
I would like to create a function for On Balance Volume (SQL Function). This
How can i return 2 values from a PL-SQL function?
Quick check to see if anyone has or knows of a T-SQL function capable

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.