Re: A simple problem!
| From: | Chris Lee | Date: | Tue, 24 Apr 2001 16:24:28 +0000 |
| Subject: | Re: A simple problem! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-50141@lists.php.net to get a copy of this message | ||
your variable scope is local not the function
function name()
{
global $variable;
}
--
Chris Lee
lee@mediawaveonline.com
""Subodh Gupta"" <subodhkgupta@satyam.net.in> wrote in message news:002b01c0cce9$aa670b60$c834d6d2@subodhgu...
Can You figure out the mistake here...??
In the following code... In the function print_entry which I am calling in some other file, I want
each entry to printed in a different colour.
$colour =
array("808080","800000","FF00FF","0000FF","008080");
$colouroffset=0;
function print_entry($row,$preserve="")
{
// walk through any arguments passed in after the first two
$numargs = func_num_args();
for ($i = 2; $i < $numargs; $i++)
{
$field = func_get_arg($i);
// This will transform a label string to a valid database
// field name - e.g., "Last Name" becomes "last_name"
$dbfield = str_replace(" ", "_", strtolower($field));
$dbvalue = cleanup_text($row[$dbfield],$preserve);
$name = ucwords($field);
print <<<EOQ
<tr>\n
<td valign=top align=right><b><font
color="#$colour[$colouroffset]">$name:</font></b></td>\n // The
problem is here.. the value of $colour[$colouroffset] is not <td valign=top
align=left><font
color="#$colour[$colouroffset]">$dbvalue</font></td>\n //
getting substituted. Can you tell me why??
</tr>\n\n
EOQ;
}
$colouroffset++;
}
Subodh Gupta
I have learned, Joy is not in things, it is in us.
You will ultimately be known by what you give and not what you get.