Jump to content

Printing out values from array using template (only says the word array)?


scristopher

Recommended Posts

Hello,

First of all I'm 100% new to using whmcs so I may have missed something obvious here. I am working on a custom addon module and need to gather the results from an array which is a sql query and print them on the modules output page. Right now I am just trying to get the text to actually display, but once I get that accomplished I plan to try to use the values in a list and possibly a dropdown menu (if thats possible). Right now it appears the query is completing successfully but only displays the word 'array' where each value is, it appears to be working to me anyways because if I change it to only get one value it returns the first result in the database.

 

This is the code I currently have.

 

Output function in t

function digicarrierSF_output($vars) {

$result = mysql_query("SELECT description from boxen LIMIT 3");
while($row = mysql_fetch_assoc($result))
{
$carrier[] = $row;
}
$smarty = new Smarty();
$smarty->assign('carrier', $carrier);
$smarty->caching = false;
$smarty->compile_dir = $GLOBALS['templates_compiledir'];
$smarty->display(dirname(__FILE__) . '/templates/digiSF.tpl');

}

 

And I've tried the code in my template

 

    {foreach $carrier as $carrier_route}
       <li>{$carrier_route}</li>
   {/foreach} 
</p>   

 

Can anyone offer some advice as to what I might be doing wrong here?

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated