AAAAAAAAAGGGGGGGHHHHHHHH!!!!!!!!!!!!!!!!
**** Warning: Invalid argument supplied for foreach() (line 31,44,50)***
Whats this mean please and how can I fix it....
Heres my code.
<?php
class Table
{
var $table_array = array();
var $headers = array();
var $cols;
function Table($headers)
{
$this->headers = $headers;
$this->cols = count($headers);
}
function addRow($row)
{
if (count($row) != $this->cols)
return false;
array_push($this->table_array,$row);
return true;
}
function addrowAssocArray($row_assoc)
{
$row = array();
foreach ( $this->headers as $header )
{
if( ! isset($row_assoc[$header]))
$row_assoc[$header] = " ";
$row[] = $row_assoc[$header];
}
array_push($this->table_array, $ow);
return true;
}
function output()
{
print "<PRE>";
foreach( $this->headers as $header )
print "<B>$header</B>";
print "\n";
foreach( $this->table_array as $y )
{
foreach( $y as $xcell )
print "$xcell ";
print "\n";
}
print "</PRE>";
}
}
$test = new table("a","b","c"
$test->addRow(array(1,2,3));
$test->addRow(array(4,5,6));
//$test->addrowAssocArray(array(b=>0,a=>6,c=>3));
$test->output();
?>
**** Warning: Invalid argument supplied for foreach() (line 31,44,50)***
Whats this mean please and how can I fix it....
Heres my code.
<?php
class Table
{
var $table_array = array();
var $headers = array();
var $cols;
function Table($headers)
{
$this->headers = $headers;
$this->cols = count($headers);
}
function addRow($row)
{
if (count($row) != $this->cols)
return false;
array_push($this->table_array,$row);
return true;
}
function addrowAssocArray($row_assoc)
{
$row = array();
foreach ( $this->headers as $header )
{
if( ! isset($row_assoc[$header]))
$row_assoc[$header] = " ";
$row[] = $row_assoc[$header];
}
array_push($this->table_array, $ow);
return true;
}
function output()
{
print "<PRE>";
foreach( $this->headers as $header )
print "<B>$header</B>";
print "\n";
foreach( $this->table_array as $y )
{
foreach( $y as $xcell )
print "$xcell ";
print "\n";
}
print "</PRE>";
}
}
$test = new table("a","b","c"
$test->addRow(array(1,2,3));
$test->addRow(array(4,5,6));
//$test->addrowAssocArray(array(b=>0,a=>6,c=>3));
$test->output();
?>