Next step to understanding PHP is by understanding how to declare functions & simply implement them & obviously how to declare variables in functions & use them beautifully on different pages without any hassle

Example extracted from Multitasking ‘action’ post
On retrieval of this we call this() function on the resultpage.php . the this() & that() functions is in a php file called functions.php()
you need to include the functions.php in resultpage.php , to do that you need to call require_once(‘functions.php”);
& declare this() function in functions.php file like:
function this()
{
$var="this called"; //this is how to declare & initialize a variable. you can store integers too but in that case you need not use any quotes. same goes for calculations
echo $var; //this is how you use it
}
Always remember you should have one common file made for the database variable & use that across the entire website. that file is your config.php file where you declare
$databasehost, $databaseuser, $databasepassword & $databasename
use require_once(‘config.php”) ; on every page where you want to use db connectivity & Use those variable to connect to database.
In fact create functions which connects you to database so that every time you want to connect you can just call that function.
Rest is on you to learn in PHP functions & variables.
Experiment & let us know!







17 Jan 2011
Posted by Aals 

