Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Accessing assigned array in PHP tags

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
bonzocs
Smarty Rookie


Joined: 19 Jul 2006
Posts: 27
Location: Cardiff - Wales

PostPosted: Tue Jan 16, 2007 11:30 pm    Post subject: Accessing assigned array in PHP tags Reply with quote

Hi All,

I have an array from a MySQL query stored in a php file.

Example:

Quote:
$smarty->assign('array_result',$myarray);


Now in the template I would like to access that array, but from within php tags.

Example:

Quote:
{php} $array_results {/php}


Does anyone know how this could be done?

Cheers
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Pap
Smarty Regular


Joined: 21 Jun 2006
Posts: 69
Location: Denver, CO

PostPosted: Wed Jan 17, 2007 2:15 am    Post subject: Reply with quote

The tags put you into PHP. You do whatever you want with it that you want to, using normal PHP code.
_________________
Don't be stupid, be a Smarty™.
Come and join the P-H-Party.
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed Jan 17, 2007 3:10 am    Post subject: Reply with quote

Instead of repeating myself, http://www.phpinsider.com/smarty-forum/viewtopic.php?t=10135

...but take note, you are better off using plugins rather than {php} tags.
Back to top
View user's profile Send private message
Hielke Hoeve
Smarty Elite


Joined: 06 Jan 2006
Posts: 406
Location: Netherlands

PostPosted: Wed Jan 17, 2007 8:21 am    Post subject: Reply with quote

use {foreach} or {section} if you want to create a list or loop over the results in your template (in case you didnt know).
_________________
Debug XHTML Compliance
SmartyPaginate
Smarty License Questions
---
(About Unix) The learning curve is full of aha! moments, such as that glorious day that the full beauty of grep and, later, find is revealed in all its majesty. --- Robert Uhl <ruhl@4dv.net>
Back to top
View user's profile Send private message
bonzocs
Smarty Rookie


Joined: 19 Jul 2006
Posts: 27
Location: Cardiff - Wales

PostPosted: Sat Jan 20, 2007 1:15 pm    Post subject: Reply with quote

Thats exactly what I was looking for - thanks guys Very Happy
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP