hello
I have some object-oriented php code. there are two involved ... a form object, and a form item object
this code loads up all the form items for a given form id from a database and then sets them into form item objects and associates them witht he current form object.
form items are grouped by parent id -- all form items have parent id=0 except the multiple options (checkbox, radio, etc) which have a parent id of the parent.
the sql loads them up ordered by parent id so all the main items come first. then when the code encounters an item with parent id !=0, it finds the form item and adds the option to it.
the problem i'm having is, all this seems to work but then later when i try to access the form items through the form object, the options are not there. here's the code.
// an excerpt of code from the form class, having just loaded a recordset of form items
for($i=0; $i < mysql_numrows($res); $i++){
$m_fi = new form_item();
$row = mysql_fetch_array($res, MYSQL_ASSOC);
$m_fi->set_from_row($row);
if($m_fi->get_parent_id() == 0){
// create the parent form id's
$this->add_form_item($m_fi);
} else {
// add the option to the parent id
foreach($arr = $this->get_form_items() as $m_item){
if ($m_item->get_id() == $m_fi->get_parent_id()){
$m_item->add_option($m_fi);
echo("count" . count($m_item->get_options())); // this always says 1
}
}
}
}
I'm thinking it has something to do with the reference, should I be using a "&" somewhere?
Please help if this makes sense!!
thanks a lot
-rdrnnr