key; $desc = $key; } // $qry = 'SELECT DISTINCT '.$this->key.','.$desc.' FROM '.$table.$sel.' ORDER BY '.$desc; $qry = 'SELECT DISTINCT `'.$key.'`,`'.$desc.'` FROM '.$table.$sel.' ORDER BY `'.$desc.'`'; // echo('
'.$qry.'
'); $res = mysql_db_query($database, $qry); while ($row = mysql_fetch_row($res)) { $values['option'][] = $row[0]; $values['value'][] = $row[1]; } return $values; } function fully_qualified_name($master_table, $field_defs, $field_name) { if (isset($field_defs[$field_name]['values']['description'])) { $fqn = $field_defs[$field_name]['values']['table'].'.'.$field_defs[$field_name]['values']['description']; } else { $fqn.= $master_table.'.'.$field_name; } return $fqn; } function create_column_list($master_table, $field_defs) { $select = 'SELECT DISTINCT'; $kwd = ' '; for ($k = 0; $k < $this->num_fds; $k++) { $fd = $this->fds[$k]; $select = $select.$kwd.$this->fully_qualified_name($master_table, $field_defs, $fd); $kwd = ','; } return $select; } function create_where_clause($master_table, $field_defs) { $kwd = ' WHERE ('; for ($k = 0 ; $k < $this->num_fds; $k++) { $fd = $this->fds[$k]; if (isset($field_defs[$fd]['values']['description'])) { $where = $where.$kwd.$master_table.'.'.$this->fds[$k].'='.$field_defs[$fd]['values']['table'].'.'.$field_defs[$fd]['values']['column'].')'; $kwd = ' AND ('; } } return $where; } function create_from_clause($master_table, $field_defs) { $tbs[] = $master_table; for ($k = 0 ; $k < sizeof($this->fds); $k++) { $fd = $this->fds[$k]; if (isset($field_defs[$fd]['values']['description'])) { if (!in_array($field_defs[$fd]['values']['table'],$tbs)) { $tbs[]=$field_defs[$fd]['values']['table']; } } } $kwd = ''; $from = ' FROM '; for ($k = 0; $k < sizeof($tbs); $k++) { $from = $from.$kwd.$tbs[$k]; $kwd = ','; } return $from; } function add_enabled () { return (stristr ($this->options, 'A')); } function change_enabled () { return (stristr ($this->options, 'C')); } function delete_enabled () { return (stristr ($this->options, 'D')); } function filter_enabled () { return (stristr ($this->options, 'F')); } function initial_sort_suppressed () { return (stristr ($this->options, 'I')); } function add_operation () { return (($this->operation == 'Add' or $this->moreadd == 'More' ) and $this->add_enabled ()); } function change_operation () { return (($this->operation == 'Change') and $this->change_enabled ()); } function delete_operation () { return (($this->operation == 'Delete') and $this->delete_enabled ()); } function filter_operation () { return (isset($this->filter) and $this->filter_enabled ()); } function displayed () { return (!isset($this->fdd[$this->fds[$k]]['options']) or ($this->add_operation() and stristr($this->fdd[$this->fds[$k]]['options'],'A')) or ($this->change_operation() and stristr($this->fdd[$this->fds[$k]]['options'],'C')) or ($this->delete_operation() and stristr($this->fdd[$this->fds[$k]]['options'],'D')) ); } function create_javascripts () { if ($this->add_operation () or $this->change_operation ()) { echo '' . "\n"; /* echo */ echo ''."\n"; } /* if ACD allowed */ } function update_record () { /* ====================================================================== Pass 3: process any updates generated from the confirmation screen displayed during Pass 2 ====================================================================== */ if ($this->saveadd == 'Save' or $this->moreadd == 'More') { /* we fill the record field names */ for ($k = 0; $k < $this->num_fds; $k++) { if ( $this->displayed() ) { if ($k == 0) { $qry = 'INSERT INTO '.$this->tb.' (`'.$this->fds[$k].'`'; } else { $qry = $qry.',`'.$this->fds[$k].'`'; } } } /* and their respective values coming in POST vars named after the field name */ for ($k = 0; $k < $this->num_fds; $k++) { if ( $this->displayed() ) { $fn = $this->get_http_post_var_by_name($this->fds[$k]); if ($k == 0) { $qry = $qry.') VALUES (\''.addslashes($fn).'\''; } else { $qry = $qry.',\''.addslashes($fn).'\''; } } } $qry = $qry.')'; // echo ''.$qry.'
'; $res = mysql_db_query ($this->db, $qry); echo ''.$qry.'
'; $res = mysql_db_query ($this->db, $qry); echo '