I dont know if this should go to the newbie area but I think it may be a little beyond that (I hope 😕).
I've got a db going with "family" details and I'm making up my classes right now to connect to them and such. What I'm trying to do right now is create first a class as a "constructor" for the generic "family" properties (i.e. "last name", "address", "phone number"...).
Then I'd like to have another class/function that will actually create instances of the "family" constructor but the variable name (or object name) would be incremented through each iteration or row in the database.
Here is an example of what I'm trying to do (with just the last name variable in play):
class family{
//family contsructor
var $LNAME;
}
class buildfam{
function createfams(){
$mainqry = new mainqry();
$result=$mainqry->mainqrystring();
$i=1;
while($row=mysql_fetch_array($result)){
//here is my rub, how do I tack on a incremented value to the end of "$fam"??
$fam= new family();
$fam->LNAME=$row['LNAME'];
$i++;
}
}
}
I've got a class that connects to my db, another class that builds my queries (either a complete listing like I'm using here or a detailed listing based on supplied arguments), and then I'm going to use other classes to actually display this information. I'd like to gather the info into an object that I can use the "display" classes to manipulate rather than having to use a ridiculously long "echo" string under the "while($row=mysql_fetch...." line.
I'm new-ish to PHP, so If I'm being a moron here, please let me know.