Crezzur.com Posted December 23, 2015 Share Posted December 23, 2015 (edited) Hey all, I need to display a list of active users in my module..However i am having issues displaying an array in a tpl file. The code you see below will only shows 1 record from the database but there are more records that needed to been shown. I have tried multiple thing but i just cant get it to work, (it showed 1 time multiple users and then broke for no reason) PHP Code $result = array(); $sql_select = 'SELECT * FROM ' . _DB_PREFIX_ . 'customer WHERE active = 1'; $result = Db::getInstance()->ExecuteS($sql_select); //$userdata = Db::getInstance()->ExecuteS('SELECT * FROM ' . _DB_PREFIX_ . 'customer WHERE active = 1'); $this->context->smarty->assign('userlist', $result); TPL Code {if isset($userlist)} {foreach $userlist as $user} <tbody> <td class="pointer fixed-width-xs center">{$user.id_customer}</td> <td class="pointer">{$user.firstname}</td> <td class="pointer">{$user.lastname}</td> <td class="pointer">{$user.email}</td> <td class="pointer">{$user.newsletter}</td> <td class="pointer">{$user.optin}</td> </tbody> {/foreach} {/if} Anyone has an idea whats wrong? Thanks in advance! Edited December 23, 2015 by Crezzur (see edit history) Link to comment Share on other sites More sharing options...
tuk66 Posted December 23, 2015 Share Posted December 23, 2015 It can the table. Try {if isset($userlist)} <table> <tbody> {foreach $userlist as $user} <tr> <td class="pointer fixed-width-xs center">{$user.id_customer}</td> <td class="pointer">{$user.firstname}</td> <td class="pointer">{$user.lastname}</td> <td class="pointer">{$user.email}</td> <td class="pointer">{$user.newsletter}</td> <td class="pointer">{$user.optin}</td> </tr> {/foreach} </tbody> </table> {/if} Link to comment Share on other sites More sharing options...
Crezzur.com Posted December 23, 2015 Author Share Posted December 23, 2015 (edited) i have tried it, but thats not the issue (it dident work) when i print_r my variable i only get 1 user (there should be 2) Mysql Table (2 users should been displayed) # id_customer, id_shop_group, id_shop, id_gender, id_default_group, id_lang, id_risk, company, siret, ape, firstname, lastname, email, passwd, last_passwd_gen, birthday, newsletter, ip_registration_newsletter, newsletter_date_add, optin, website, outstanding_allow_amount, show_public_prices, max_payment_days, secure_key, note, active, is_guest, deleted, date_add, date_upd '1', '1', '1', '1', '3', '1', '0', '', '', '', 'John', 'Delta', '[email protected]', 'e60c028ad85e70675fa7559ce3979db8', '2015-10-26 05:09:47', '1970-01-15', '1', '', '2013-12-13 08:19:15', '1', '', '0.000000', '0', '0', '05e2fbb910f3cf27a8eeef5efc220722', '', '1', '0', '0', '2015-10-26 11:09:47', '2015-10-26 11:09:47' '2', '1', '1', '1', '3', '1', '0', NULL, NULL, NULL, 'Aerts', 'Jaimy', '[email protected]', 'ba5ff3d22047f61c1ac9e95d43a26414', '2015-12-22 14:39:31', '1998-03-17', '1', '81.241.181.199', '2015-12-22 20:39:31', '1', NULL, '0.000000', '0', '0', '942856ca1f795320f7bfe05400585d57', NULL, '0', '0', '0', '2015-12-22 20:39:31', '2015-12-22 21:01:39' Array ( [0] => Array ( [id_customer] => 1 [id_shop_group] => 1 [id_shop] => 1 [id_gender] => 1 [id_default_group] => 3 [id_lang] => 1 [id_risk] => 0 [company] => [siret] => [ape] => [firstname] => John [lastname] => Delta [email] => [email protected] [passwd] => e60c028ad85e70675fa7559ce3979db8 [last_passwd_gen] => 2015-10-26 05:09:47 [birthday] => 1970-01-15 [newsletter] => 1 [ip_registration_newsletter] => [newsletter_date_add] => 2013-12-13 08:19:15 [optin] => 1 [website] => [outstanding_allow_amount] => 0.000000 [show_public_prices] => 0 [max_payment_days] => 0 [secure_key] => 05e2fbb910f3cf27a8eeef5efc220722 [note] => [active] => 1 [is_guest] => 0 [deleted] => 0 [date_add] => 2015-10-26 11:09:47 [date_upd] => 2015-10-26 11:09:47 ) ) Edited December 23, 2015 by Crezzur (see edit history) Link to comment Share on other sites More sharing options...
Crezzur.com Posted December 23, 2015 Author Share Posted December 23, 2015 Damn i'm going to kick myself to the head i have deactivated 1 of the accounts by accident. For people that are looking on how to export an array list to .tpl -> PHP Code: $userdata = Db::getInstance()->ExecuteS('SELECT * FROM ' . _DB_PREFIX_ . 'customer WHERE active = 1'); $this->context->smarty->assign('userlist', $userdata); TPL Code: {if isset($userlist)} {foreach $userlist as $user} <tbody> <td class="pointer fixed-width-xs center">{$user.id_customer}</td> <td class="pointer">{$user.firstname}</td> <td class="pointer">{$user.lastname}</td> <td class="pointer">{$user.email}</td> <td class="pointer">{$user.newsletter}</td> <td class="pointer">{$user.optin}</td> </tbody> {/foreach} {/if} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now