Here's my UDT called UserListing
$gCms = cmsms();
$db = $gCms->getDb();
$sql = "SELECT * FROM " . cms_db_prefix() . "module_feusers_users";
$dbresult = $db->Execute($sql);
$count = $dbresult ->RecordCount();
$result = array();
while($dbrow = $dbresult->FetchRow()) {
$result[] = $dbrow;
}
$smarty ->assign(result,$result);
$smarty ->assign(count,$count);
and my page:
{UserListing}
<p>{$count} records on file</p>
{foreach from=$result item='entry'}
<p>Email:{$entry.email}</br>
{/foreach}
$count shows correctly so I know result is being passed as I get
the correct number of lines from the loop
But the loop shows no $entry.email or any other field
What am I missing ?
db access in CMSMS 2
Re: db access in CMSMS 2
Try the following to see what is inside {$entry}...
Code: Select all
{foreach from=$result item='entry'}
{$entry|print_r:1}
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Re: db access in CMSMS 2
Here's 1 record from the loop:
Array ( [id] => 134 [username] => Anderson [password] => ---------------------------------------------- [createdate] => 2014-07-31 20:38:21 [expires] => 2014-07-31 23:59:59 [nonstd] => 0 [disabled] => 0 [salt] => --------------------------------------[force_newpw] => 0 [force_chsettings] => 0 )
Array ( [id] => 134 [username] => Anderson [password] => ---------------------------------------------- [createdate] => 2014-07-31 20:38:21 [expires] => 2014-07-31 23:59:59 [nonstd] => 0 [disabled] => 0 [salt] => --------------------------------------[force_newpw] => 0 [force_chsettings] => 0 )
Last edited by Jo Morg on Wed Oct 05, 2016 4:12 pm, edited 1 time in total.
Reason: Security
Reason: Security
Re: db access in CMSMS 2
<p>User:{$entry['username']} ID:{$entry['id']} </br>
WORKED !!!
Thanks so much. I've spent hours trying to figure it out
WORKED !!!
Thanks so much. I've spent hours trying to figure it out
Re: db access in CMSMS 2
In Smarty you can use both the PHP array notation and the Smarty dot notation to access arrays:
Apparently you were trying to get data that wasn't there to begin with.
Code: Select all
{$entry['username']} = {$entry.username}
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!