TT Web Site Manager Item management: PHP with SQL wrapper items
Item management: PHP with SQL wrapper items

These items are a combination of PHP and SQL code which give the TT Web Site Manager one of its more powerful features. An SQL query is executed, and for each result in the record set returned a piece of PHP code is executed. The results of the current line returned by the SQL query are made available to the PHP code as an array $tt_data whose indexes are the table column names.

This type of item is most often used to populate an HTML table from an SQL query. The SQL query is executed and for each line on the record set returned the PHP code outputs a table row.

There are two textareas in the form for this type of item. The upper one contains the PHP code and the lower one contains the SQL query. Just as with the PHP items, any static content in the PHP code must be contained within ?> and <? as it would be in a normal PHP file. PHP variables may be used within the SQL query but they must be enclosed whthin concatenation operators and quote marks as if they were being combined into a string by some PHP code.

Item name
Container
Type

Enter PHP code here. Escape static content using ?> and <?. Each line of the result set from the SQL query is returned as an array $tt_data whose indexes are the table column names.
Code


Enter SQL code here.
PHP variables may be used but they must be enclosed within concatenation operators and quote marks.
E.G. insert into tables(data) values('" . $data . "')
select data from table where ref=" . $data . "

SQL

Item management: PHP items Contents Item management: SQL query items