March 2004 Technical Tip Ė Dynamic TABINDEX with PHP
PHP can even be used to access MySQL databases (we talked about MySQL in our January and February articles.) But even if all you know is HTML, you can benefit from some simple PHP knoweldge. Consider the following web page:
The tab key will cause movement through the table from left to right, top to bottom. But what if you wanted to move from top to bottom, left to right instead? You could use the tabindex attribute in the <input> tag to control tabbing, for example:
<td><input type="text" name="r1c1" value="row 1 clm 1" tabindex="11"/>
Maintaining code like this is easy if the table is small, but not so with a large table. It would be nice if the tabindex value could be dynamically generated, and that is just what you can do with PHP. PHP tags begin with <? and end with ?>. The echo command shows the value of its parameters, that value therefore being included in the final HTML code. The above could be changed as follows:
<td><input type="text" name="r1c1" value="row 1 clm 1" tabindex="<? echo ($tab++)."1"; ?>"/>
Thereís a little more to it than this, so be sure to check out the complete source at http://www.caliberdt.com/tips/tabindex.txt. (Note: I have used a .txt extension instead of .php or you might not be able to view it!)
Now to answer the question posed at the beginning of this article: LAMP stands for Linus + Apache + MySQL + PHP, all of which are open source. We hope you will consider Caliber Data Training for all your training needs: let us shed some light on LAMP!