So here is what I am thinking.
A function page that would handle all the boring HTML formatting.
and a page where I would pass the arguments for the formatting of the HTML, including the output text.

This would help in the fact that I could just include the functions in all the PHP scripts without having to type all the HTML behind it.

This is what I have so far:

<?php

function.inc.php

function body($bgColor)
{
	echo "<body bgcolor='$bgColor'>";
}
function table($tableAlign,$tableBorder,$tableWidth)
{
	echo "<table align='$tableAlign' border='$tableBorder' width='$tableWidth'><tr>";
}

function td($tdAlign,$tdWidth,$fontFace,$fontSize,$fontColor,$tdData)
{
	echo "<td align='$tdAlign' width='$tdWidth'><font face='$fontFace' size='$fontSize' color='$fontColor'>$tdData</td>";
}

function close()
{
	echo "</tr></table>";
}


html.output.php

body('#000000');
table('left','1','50%');
td('center','50%','Verdana','3','#FFFFFF','This is a test');
close();

Have any of you folks done this or have any better ideas?
Thanks for the help.
~az

    Nice actually... but what about this? Maybe have default parameters...

    
    function body($bgColor = "black") {
    echo "<body bgcolor='$bgColor'>";
    }
    
    #That way, if you do not put a param in... then it defaults to black..
    
    body();
    
    #That will make the page black, otherwise it will try to use the color you enter...
    
    

    How about that...?

      It is certainly an idea, but I would like to never have to touch that function page...ever.

      My thinking is I could just format everything using the html page. This way, I am not stuck with a black page, every time I use the function. The functions would be used as a template for the formatting.

        I know, but you could just call, and if you ever accidently left out a param, it wouldn't give an "Invalid number of arguments" error... so you could call a function, have default values, and not worry about that error as well.. hehe

          hey Azazeal want to work on something like this together? 🙂 It would be useful... In fact I've wanted to do it a long time, but never get around to it... now you've put me in the mood snickers so what do ya say?

            Sure.
            I may not be very responsive at times, as it is not frequent that I visit this forum on work hours. Or be able to go back and forth.
            But I am willing to give it a shot.
            Be aware that I am a bit of a newbie, but have a fair knowledge.

            I think that another friend of mine had some of this done. I am going to ask what he has again..Then I will post it here.

            ~az

              When I create a PHP application I have have three pages. Kinda like a three tier app. If I use a database application as an example:

              I will have - main.php
              functions.php
              core.php

              main.php
              This file will contain just the HTML and PHP to do with the display of the page.
              e.g.

              <html>
              <head><title>DB App</title></head>
              <body>
              <table>
               <tr>
                <td>Nav Bar</td>
               </tr>
               <tr>
                <td><?php displayquery(); ?></td>
               </tr>
              </table>
              </body>
              

              functions.php
              This file contains the functions which actually output the HTML data into the browser. They format the data accordingly with HTML tags and convert special charcters.
              e.g.

              <?php
                function displayquery()   {
                  $result = getquery();
              
              /* output html with all the rows of the query in a table */
              
                }
              

              core.php
              This file contains the functions which are concerned with obtaining the data from post/get variables connecting to the data base and passing the data raw data in the form of arrays of other convinent variables. The data is maniuplated by these functions and validity can take place to..

                Write a Reply...