prova


<!ELEMENT datasource (dbclass, sql, dbname, dbserver, dbuser, dbpasswd, varname)>

Set the source info for the current block

 

Parent:

block
 

Childs:

dbclass
sql
dbname
dbserver
dbuser
dbpasswd
varname
function
 

Attributes:

 

Note:

The block is a row repeated many times. Each time the 'block' gets a new data row from its source, in this way you may print tables from sql query or from arrays.
Two type of sources are available: database or array.
The first one gets its data from the output of sql query. In this case you need to supply the information about the query (sql), the database name (dbname), the server where locate it (dbserver), the user and the password.
The tag dbclass set which php class the module should to use to connect to the database. See the <link dest='sptpl_class_db.html'>class_db</link> page for more information about the available class. The second way, the array, get its data from a global array. That array should emulate a database table. See the following example:

The following array:
$foo=array( array('a' => 11,
'b' => 12),
array('a' => 21,
'b' => 22),
array('a' => 31,
'b' => 32)
);

or the following table:
+----+----+
| A | B |
+----+----+
| 11 | 12 |
+----+----+
| 21 | 22 |
+----+----+
| 31 | 32 |
+----+----+
give the same output.

 

Examples:

Data form array foo:
$GLOBALS['foo']=array( array('a' => 11,
'b' => 12),
array('a' => 21,
'b' => 22),
array('a' => 31,
'b' => 32)
);

Configuration

foo

Data from database


db_mysql
select a, b from mytable
mydbname
localhost
MyName
MyPassword