i need PHP Help pleaase!!?

Jaclyn S

New member
Hey
i need help with PHP

on a page called functions i have the variable called $total
...
i wanna display $total on another page in a table
what code do i need to enter to make this happen...?

i've tried <?php include $total ?>
and <?php $total ?>
i'm not sure what i need to put!
<?php include("functions.php"); ?>
doesn;t work - i need to to display $total... where do i put it in that statement?
 
First you need to include the file, and then print out the variable. Example:

Code for functions.php

<?php
$total = 34;
?>

Code for main page:

<?php
include "functions.php";
echo $total;
?>

Note that if $total is defined inside a function, you need to use the "global" keyword inside the function to make sure $total is accessible from outside the function. In that case, the functions page would look like:

<?php
function foo(){
global $total;
$total = 34;
}
foo();
?>
 
in your php include statement, you need to put the name of the functions php file:
example: <?php include("functions.php"); ?>
 
Back
Top