Sunday, March 4, 2007

Dynamic HTML Table PHP Function - Very useful and FREE

As I promised, I would post the PHP Function that you can use to create dynamic tables that contain pictures like in my previous post:

< ?php
function cc($content,$path,$width=NULL,$height=NULL,$align="center",$valign="top")
{
////margins
$margin_right_up=$path."margin-ru.png";
$margin_right_down=$path."margin-rd.png";
$margin_left_up=$path."margin-lu.png";
$margin_left_down=$path."margin-ld.png";
////borders
$left=$path."left.png";
$right=$path."right.png";
$up=$path."up.png";
$down=$path."down.png";
////center
$center=$path."center.png";

?>

< table border="0" cellspacing="0" cellpadding="0">

< ?php td_pic($margin_left_up);? >
< ?php td_pic($up,$width);?>
< ?php td_pic($margin_right_up);? >
< /tr>
< tr>
< ?php td_pic($left,NULL,$height);?>
< td background="< ?php echo $center;? >" valign="< ?php echo $valign;? >" nowrap="nowrap" align="< ?php echo $align;? >" >< ?php content($content);? >< /td>
< ?php td_pic($right,NULL,$height);? >
< /tr>
< tr>
< ?php td_pic($margin_left_down);? >
< ?php td_pic($down,$width);? >
< ?php td_pic($margin_right_down);? >
< /tr>
< /table>
< ?php

}
?>
// Ok. I know it has a lot of values as a function, but most of them are default. You can set them or not. The idea of this function is that you can cut the picture as shown in the previous tutorial and save those pictures according to the names of each...
You can see in the code the commented variables with the margins and borders and center ....
So basically you just need to create a folder where you put all these....and then you do the following:

You want to have the new form filled with some content.... so...you set the path on the $content Variable.(path to the file you want to show in the content...)

You must set the path to the picture files.This is done in the $path variable..the second one in the function.

The rest of the variables are $width, $height(if you want a specific width and height), $align (where to align the content), and of course $valign(if you want to choose where to align it).
This function is a little flexible as you may see.....
You can do a lot of work very fast with it, and you can change the code how ever you like, in order for it to look like you want it to.....

Enjoy,
Cy21

No comments: