Web Toolbar by Wibiya

Archive for the ‘Others’ Category

Access Request variables from smarty templates

Tuesday, January 25th, 2011

In smarty templates you can access Request variables available in PHP scripts using the reserved template variable {$smarty}.  Request variables include $_GET, $_POST, $_SERVER, $_ENV, $_COOKIE and $_SESSION.

Tips to speed up mysql queries

Monday, January 24th, 2011

1. Instead of VARCHAR, BLOB or TEXT, Use CHAR type when possible. if values of a column have constant length: MD5-hash (32 symbols), ICAO or IATA airport code (4 and 3 symbols), BIC bank code (3 symbols), etc. Data in CHAR type columns can be found faster rather than in ...

How to load data into table from a text file ?

Monday, January 24th, 2011

Here we are assuming that we have a  table with given structure: [sql] CREATE TABLE teasttable ( prkey int(11) NOT NULL auto_increment, names varchar(20), score int, timeEnter timestamp(14), PRIMARY KEY  (prkey) ); [/sql]

Smarty – Passing ‘title’ variable to header template

Sunday, January 23rd, 2011

Generally when majority of your templates use the same headers and footers, it is obviously a good choice to split those out into their own templates and include them. But what if the header needs to have a different title, depending on what page you are coming from? For this ...

Smarty – Handle blank variables

Sunday, January 23rd, 2011

Sometimes instead of printing an empty variable you may need to print a default value. For example printing a sign "*" instead of printing nothing so that the page should appear in understandable form. Yes! you can use rather most of the people use {if} statement for this but there ...

Alternate css styles in smarty using {cycle} tag

Saturday, January 22nd, 2011

Displaying rows or tables of information in alternate background colors is a nice way to improve readability. You may have used alternate css style in template using  {if} tag but there is a smarty tag {cycle} which you can use to set the alternating CSS styles. Here is a sample code ...

How to access template variables from PHP script ?

Saturday, January 22nd, 2011

Using Smarty method get_template_vars(), you can access the smarty template variables  in PHP scripts. However, these template variables are only available after or  during the execution of template. The other way to use those template variables can be achieved by embedding PHP code directly into the smarty template using {php}  ...