I have an admin panel that each section contains a set of tools so on each
page I can set $toolsneeded = "admin" or $toolsneeded = "employees"; etc.
I keep recieving this error:
Warning: Division by zero in /home/www/website/admin/include/adminclass.php
on line 250
Warning: Variable passed to each() is not an array or object in
/home/www/website/admin/include/adminclass.php on line 251
This is line 250: $height = 100/count($tools);
Here is the page that uses the class.
<?
include ('include/adminclass.php');
$adminroot = new adminpage();
$title = "Administration Portal";
$redux = "Hello Some Temporary Content";
$adminroot->SetContent($redux);
$toolsneeded = "admin";
$adminroot->SetTools($toolsneeded);
$adminroot->Display($employeeid,$password,$title);
?>
Here is my class file with some of the functions removed for brevity. I have
real problems understanding $this-> so you may find that Im using it in the
wrong place or not using it where I should be.
<?
##
##CLASS DECLARATION
##
class ADMINPAGE
{
//class adminpage's attributes
##
##VARIABLE DECLARATION
##
var $toolsneeded;
var $tools;
var $content;
var $toolsadmin = array("process orders" => "orders_root.php",
"products" => "products_root.php"
);
##
##SET FUNCTIONS
##
function SetContent($newContent)
{
$this->content = $newContent;
}
function SetTools($newTools)
{
$this->toolsneeded = $newTools;
}
##
##DISPLAY FUNCTION
##
function Display($employeeid,$password,$title)
{
session_start();
session_register("employeeid");
$count = $this -> VerifyLogin($employeeid,$password);
switch($count)
{
case "1":
$this -> DisplayHeader($title,$employeeid);
echo "<center><br><table width=\"500\"><tr><td>";
$this -> DisplayMenu($this->buttons);
echo "<br>";
$this -> DisplayContent($this->tools,$this->content);
echo "</td></tr></table></center><br>";
$this -> DisplayFooter();
break;
default:
$title = "Please Try Again";
$employeeid = "";
$this -> DisplayHeader($title,$employeeid);
echo "<center><br><table width=\"500\"><tr><td valign=\"top\">";
echo "Your username and password combination is incorrect. Please try
again.";
$this -> DisplayLogInForm();
echo "</td></tr></table></center><br>";
$this -> DisplayFooter();
break;
}
}
##
##DISPLAY TOOLS FUNCTION
##
function DisplayTools($tools)
{
echo "<table width = \"100%\" bgcolor=\"#333333\" cellpadding=\"1\"
cellspacing=\"0\"><tr><td>";
echo "<table width=\"100%\" bgcolor=\"#ff6600\" cellpadding=\"5\"
cellspacing=\"0\"><tr><td valign=\"middle\" align=\"right\">";
echo"<table width=\"100%\" bgcolor=\"#333333\" cellpadding=\"1\"
cellspacing=\"0\"><tr><td>";
echo"<table width=\"100%\" height=\"20\" border=\"0\" cellpadding=\"3\"
cellspacking=\"0\" bgcolor=\"whitesmoke\"><tr>";
###
###Line 250
###
$height = 100/count($tools);
###
###
while(list($name,$url) = each($tools))
{
$this ->ToolsLayout($height,$name,$url);
}
echo "</tr></table>";
echo "</td></tr></table>";
echo "</td></tr></table>";
echo "</td></tr></table>";
}
##
##TOOLS LAYOUT FUNCTION
##
function ToolsLayout($height,$name,$url)
{
echo "<td width =\"$width%\" valign=\"middle\">";
echo "<div align=\"center\">[ <a href = \"$url\">$name</a> ]</div></td>";
}
function ToolSelected($toolsneeded)
{
switch($toolsneeded)
{
case "admin":
DisplayTools($toolsadmin);
break;
case "orders":
echo "Order Tools";
break;
default:
echo "Your Tools do not work";
}
}
##
##DISPLAY CONTENT FUNCTION
##
function DisplayContent($toolsneeded,$content)
{
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width="100%" border="0" cellpadding="1" cellspacing="0"
bgcolor="333333">
<tr>
<td valign="top">
<table cellspacing="0" cellpadding="3" border="0" bgcolor="#FF6600"
width="100%">
<tr>
<td width="18%" valign="top">
<table cellspacing="1" cellpadding="0" border="0"
bgcolor="#333333">
<tr>
<td>
<table cellpadding="2" cellspacing="0" border="0" bgcolor="#ffffff"
width="100%">
<tr><td><img
src="/images/designelements/spacer.gif" width="130" height="1"></td></tr>
<tr>
<td>
<?
$toolsneedeed = $this->DisplayTools($toolsneeded);
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td width="82%" rowspan="2" align="right" valign="top">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td> <table width="100%" border="0" cellpadding="1" cellspacing="0"
bgcolor="#333333">
<tr>
<td>
<table width="100%" border="0" cellpadding="1" cellspacing="0"
bgcolor="whitesmoke">
<tr bgcolor="#333333"><td colspan="3"><img
src="/images/designelements/spacer.gif" width="300" height="1"></td></tr>
<tr bgcolor="#333333"><td width="2%">
<img src="/images/designelements/spacer.gif" width="2" height="10">
</td>
<td width="93%" class="small"><font color="#FFFFFF"><b>admin</b></font>
</td>
<td><img src="/images/designelements/spacer.gif" width="1" height="1"></td>
</tr>
<tr bgcolor="#333333"><td colspan="3"><img
src="/images/designelements/spacer.gif" width="300" height="1"></td></tr>
<tr valign="top">
<td colspan="3">
<div align="left">
<table cellspacing="5" width="100%">
<tr><td><?
echo $content;
?>
</tr></td>
</table>
</div>
<tr>
<td colspan="2" align="center" class="small">
<img src="../images/designelements/spacer.gif" width="1"
height="1"></table></td>
</tr>
</table>
<br></td>
</tr>
<tr>
<td align="right" class="small">a and i balancing administration</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<?
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php