I posted this question a while back, but never got it working.
The idea that I have be the following method in my class, is that I dont want to produce any html from the object created, but only to produce the values for me.
I want those values stored in an assoc array, so that when I call the obect through some procedural, I want to be able to loop out that assoc array the has been stored in the objects mem...
function returnUser()
{
dbConnect::dbConnect();
if($this->dbConnect == false)
{
return $this->error = "connection faild";
}
$this->query = "SELECT * FROM user";
$result = mysql_query($this->query) or die(mysql_error());
while($data[] = mysql_fetch_assoc($result)){
//**** this is where I want to store the assoc array to loop out latter
// more than 1 user in record set to loop out
$this->aData = array(array($aData['uName'], $aData['uSurname']));
return $this->aData;
//**** but having problems returning the values in an array to loop out
}
}
so when called the new object
// this is where the second problem comes in ....to loop out the object
$obj = new myUser();
$data = $obj->aData;
//**This is how Im hoping to have the values stored as to loop out
$data = array(
array("uName" => "Joe", "uSurname" => "Soap"),
array("uName" => "Bob", "uSurname"=>"Long")
);
//***************************************************
foreach($data as $setName)
{
foreach ($setName as $var=>$val)
{
print "<td>" . $var. "</td><td>" . $val . "</td>";
}
}
Bit of a long one but thanks in advance
P.S If anyone knows of a better way to do this....Im all ears.
Thanks