E-Mail |
These pages were made with a MSN webTV and are only viewable with a webTV. To see the pages on a computer you may download (Windows compatible) the WebTV viewer. Click on file and enter the URL for viewing as seen on webTV. | ||||||||||||||||
This is a tute on how to use PHP for gradtable art. You will need a PHP enabled server in order to create this art with php. Php byte code is very similar to Javascript byte code. If you are familiar with Javascript you may want to go to my other site that compares these two scripts. JAVASCRIPT AND PHP | ||||||||||||||||
Javascript is not required to learn this method with php, so if you know html, read on. | ||||||||||||||||
First here is a table with audioscope coded in html. We are going to look at this code and change it to php. | ||||||||||||||||
| ||||||||||||||||
Here is the HTML code for the above table. | ||||||||||||||||
<table border=0 cellspacing=0 cellpadding=0><tr><td>
<audioscope width=15 height=15 leftoffset=5 rightoffset=5 leftcolor=ffffff rightcolor=ffffff gain=10 bgcolor=000000></td> <td bgcolor=ffcfff gradcolor=000000 gradangle=140 width=15 height=15></td> <td bgcolor=ffcfff gradcolor=000000 gradangle=-140 width=15 height=15></td><td> <audioscope width=15 height=15 leftoffset=5 rightoffset=5 leftcolor=ffffff rightcolor=ffffff gain=10 bgcolor=000000></td> </tr><tr> <td bgcolor=000000 gradcolor=ffcfff gradangle=140 width=15 height=15></td><td> <audioscope width=15 height=15 leftoffset=5 rightoffset=5 leftcolor=ffffff rightcolor=ffffff gain=10 bgcolor=000000></td> <td> <audioscope width=15 height=15 leftoffset=5 rightoffset=5 leftcolor=ffffff rightcolor=ffffff gain=10 bgcolor=000000></td> <td bgcolor=000000 gradcolor=ffcfff gradangle=-140 width=15 height=15></td></tr><tr> <td bgcolor=ffcfff gradcolor=000000 gradangle=-140 width=15 height=15></td><td> <audioscope width=15 height=15 leftoffset=5 rightoffset=5 leftcolor=ffffff rightcolor=ffffff gain=10 bgcolor=000000></td> <td> <audioscope width=15 height=15 leftoffset=5 rightoffset=5 leftcolor=ffffff rightcolor=ffffff gain=10 bgcolor=000000></td> <td bgcolor=ffcfff gradcolor=000000 gradangle=140 width=15 height=15></td></tr><tr><td> <audioscope width=15 height=15 leftoffset=5 rightoffset=5 leftcolor=ffffff rightcolor=ffffff gain=10 bgcolor=000000></td> <td bgcolor=000000 gradcolor=ffcfff gradangle=-140 width=15 height=15></td> <td bgcolor=000000 gradcolor=ffcfff gradangle=140 width=15 height=15></td><td> <audioscope width=15 height=15 leftoffset=5 rightoffset=5 leftcolor=ffffff rightcolor=ffffff gain=10 bgcolor=000000></td> </tr></table> | ||||||||||||||||
I have put these codes in to 8 different colors to show how it can be translated in to PHP. Each color represents a table cell that is duplicated in the code. In php we do not have to repeat these cells, but rather, just name them once. This name is called a variable and we call that variable every time we want that cell. A variable can be named with anything you want. To keep the code small you can use abbreviations that mean something to you or even just a single letter. The name begins with a dollar sign followed by the name, such as $table. After the $variables are set, you call them for printing with echo followed by the variables in the order they should be printed. This order is called a String. The whole PHP code will look like this: | ||||||||||||||||
| ||||||||||||||||
| ||||||||||||||||
<?php $tab = "<table border=0 cellspacing=0 cellpadding=0><tr>"; $aud = "<td><audioscope width=15 height=15 leftoffset=5 rightoffset=5 leftcolor=ffffff rightcolor=ffffff gain=10 bgcolor=000000></td>"; $wh = "<td bgcolor=000000 gradcolor=ffcfff gradangle=140 width=15 height=15></td>"; $whn = "<td bgcolor=000000 gradcolor=ffcfff gradangle=-140 width=15 height=15></td>"; $bl = "<td bgcolor=ffcfff gradcolor=000000 gradangle=140 width=15 height=15></td>"; $bln = "<td bgcolor=ffcfff gradcolor=000000 gradangle=-140 width=15 height=15></td>"; $row = "</tr><tr>"; $et = "</tr></table>"; echo $tab, $aud, $bl, $bln, $aud, $row; echo $wh, $aud, $aud, $whn, $row; echo $bln, $aud, $aud, $bl, $row; echo $aud, $whn, $wh, $aud, $et; ?> | ||||||||||||||||
And here is the PHP table from that code. Don't forget to name your file with a php extension, and not html. | ||||||||||||||||
| ||||||||||||||||
NESTED VARIABLES: You may use nested variables in php but they are written slightly different from single variables. These can be accomplished by the Heredoc Syntax in php. This code tells the parser to print out everything just as is written between the codes. The opening line for nesting is: $var=<<<EOT and the closing line is EOT; (end of text). If you put commas inbetween the codes the commas would show in the output. Here is an example of the above variables nested. | ||||||||||||||||
<?php $nest=<<<EOT $tab $aud $bl $bln $aud $row $wh $aud $aud $whn $row $bln $aud $aud $bl $row $aud $whn $wh $aud $et EOT; echo $nest; ?> | ||||||||||||||||
| ||||||||||||||||
With the Heredoc command there must be absolutely no spaces after the EOT and the EOT; and the final EOT; must be on a line by itself in order for this command to work. You may use audioscopes, transparency, images within the td cells. Working with PHP however you have to save your file before you can view the page. It will not show on a Test bed or in your file manager's preview. You may also get error mesages. For more information on this go to the Javascript and PHP page link above. You will also find more examples there as well as a sample of how to include different widths for stacked tables by including it in the echo command. |
|