I have defined a function, the problem is I can't get it to see/use variables defined outside of this function. The variables are defined at the top of the page before anything else is done, then the function is defined, then the function is called. I can echo the variables outside the function and they show up correctly, when I echo them inside the function they won't show. Code snippet below:
<?
if ($font == "l") {
$font1 = "5";
$font2 = "3"; }
if ($font == "m") {
$font1 = "4";
$font2 = "2";}
if ($font == "s") {
$font1 = "3";
$font2 = "1"; }
$dateent = date("m/d/Y");
echo $font . '<br>';
echo $font1 . '<br>';
echo $font2 . '<br>';
?>
<?
function writetable($job)
{
echo '<br>';
echo $font . '<br>';
echo $font1 . '<br>';
echo $font2 . '<br>';
if ($hours = "All" || $jobstatus = "Active") {
$db = mysql_connect("localhost", "user", "password");
mysql_select_db("hprhs1",$db);
$result = mysql_query("SELECT * FROM joblist WHERE jobtype like '$job' ",$db);
$results = mysql_query("SELECT count(id) FROM joblist WHERE jobtype like '$job' and jobstatus = 'Active' ",$db);
$row = mysql_fetch_array($results);
//echo "There are $row[0] matching entries in the database.";
$number = round($row[0]/2);
$count=1;
if ($myrow = mysql_fetch_array($result)) {
printf("<tr>\n<td colspan=2 align=center><b><FONT SIZE='". $font1 . "'>%s</FONT></b>\n", $myrow["jobtype"]);
echo "</td>\n</tr>\n<tr><TD VALIGN='top' WIDTH='50%'>";
//echo "<table border=0>\n";
//printf("<tr><td valign=top>\n");
while ($myrow = mysql_fetch_array($result)) {
if ($myrow[jobstatus] == 'Active') {
printf("<B><FONT SIZE='". $font2 . "'>%s/%s</FONT><BR></B><FONT SIZE='". $font2 . "'>%s %s.</FONT><br>\n", $myrow["jobtitle"], $myrow["deptname"], $myrow["jobreq"], $myrow["workhours"]);
$count = $count + 1;
if ($count == $number){
printf("</td>\n<td valign=top>\n"); }
}
}
}
}
printf("</tr>\n");
}
Any help is apreciated.
moonie 😉