Ok, help me out.
I started working on a website and made some standard functions for the tables.
Now I have a function called openTable which is as follows:
function openTable($header) //opening van de tabel
{
$tablewidth=400; //breedte tabel
print("<table bgcolor=\"#000000\" cellpadding=\"0\" cellspacing=\"1\" width=\"$tablewidth\">
<tr>
<td colspan=\"2\" bgcolor=\"$tablecolor\">
<font color=\"#FFFFFF\"><b>$header</b></font>
</td>
</tr>
<tr>
<td>
<table width=\"$tablewidth\" bgcolor=\"#F0F0F0\" border=\"0\" background=\"http://www.eticoll.nl/art/table.gif\">\n");
}
Same way there is a function called closeTable, but works the same.
I put this function in my file which I include in every page, called database.php
Now what I want to do:
I've an admin-part of the website and a public part.
In public part the tables should be red, in adminpart they should be purple.
Both admin and public are build the same way. They have an index.php which parses the content, so including the database.php once on index.php works fine for all pages.
As you see in openTable() I only collect the variable $header, which works offcourse fine.
$tablewidth is given in the function, so it works fine also.
But becuz I wanted the different colors I made the bgcolor also a variable, called $tablecolor.
What I want to do is give $tablecolor in the index.php of admin and public part, so that it works in the function. But the scope of the function won't accept it.
Now, I know that I could do it this way: function openTable($header, $tablecolor) { etc. }
but that would mean I have to change a freaking lot of pages and I just KNOW there must be a way to give $tablecolor once...
But I can't find it....
Someone tell me 🙂
So question is, how to give a variable to a function without having to add it in every functioncall?