|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
KyleFYI Smarty n00b
Joined: 25 Mar 2012 Posts: 1
|
Posted: Sun Mar 25, 2012 5:40 pm Post subject: Smarty array with a sql db? |
|
|
Okay I want to do a array and grab the items from a sql db.
This is what I have so far.
PHP
Code: |
$query = mysql_query('SELECT * FROM user');
$data = array('users');
while($row = mysql_fetch_assoc($query)) {
$data['users'][] = $row[];
} |
TPL
Code: |
<html>
{foreach $users as $row}
{$row.username}
{$row.email}
{/foreach}
</html> |
But it comes up with this error.
Fatal error: Cannot use [] for reading in C:\xampp\htdocs\sdb\admin\users.php on line 6
I can't seem to fix it. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sun Mar 25, 2012 8:22 pm Post subject: |
|
|
Code: | $query = mysql_query('SELECT * FROM user');
$data = array('users');
while($row = mysql_fetch_assoc($query)) {
$data['users'][] = $row;
}
|
|
|
Back to top |
|
|
|
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
|