'.$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, $format='N') { 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.'`'; if ( (isset($field_defs[$field_name]['format'])) && ($format == 'Y') ) { $fqn = 'DATE_FORMAT('.$fqn.',\''; $fqn = $fqn.'%'.$field_defs[$field_name]['format'][0].$field_defs[$field_name]['format'][3]; $fqn = $fqn.'%'.$field_defs[$field_name]['format'][1].$field_defs[$field_name]['format'][3]; $fqn = $fqn.'%'.$field_defs[$field_name]['format'][2].'\')'; } } 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, 'Y'); $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 == $this->labels[1] or $this->saveadd == $this->labels[7] ) and $this->add_enabled ()); } function more_operation () /*Add More*/ { return (($this->moreadd == $this->labels[8]) and $this->add_enabled ()); } function change_operation () { return (($this->operation == $this->labels[2] or $this->savechange == $this->labels[7] ) and $this->change_enabled()); } function delete_operation () { return (($this->operation == $this->labels[3] or $this->savedelete == $this->labels[7] ) and $this->delete_enabled()); } function filter_operation () { return (isset($this->filter) and $this->filter_enabled ()); } function displayed($k) { return (!isset($this->fdd[$this->fds[$k]]['options']) or ($this->add_operation() and stristr($this->fdd[$this->fds[$k]]['options'],'A')) or ($this->more_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() or $this->more_operation()) { echo '' . "\n"; /* echo */ echo ''."\n"; } function do_add_record() { $qry = ''; for ($k = 0; $k < $this->num_fds; $k++) { if ( $this->displayed($k) ) { $fd = $this->fds[$k]; if ($qry == '') { $qry = 'INSERT INTO '.$this->tb.' (`'.$fd.'`'; } else { $qry = $qry.',`'.$fd.'`'; } } } $val = ''; for ($k = 0; $k < $this->num_fds; $k++) { if ( $this->displayed($k) ) { $fd = $this->fds[$k]; $fn = $this->get_http_post_var_by_name($fd); if (isset($this->fdd[$fd]['format'])) /*handle fancy date formats*/ { $l = $this->fdd[$fd]['format'][3]; /*delimiter*/ $fna = explode($l,$fn); /*split using user's delim*/ $fn = $fna[strpos($this->fdd[$fd]['format'],'y')]; /*Year*/ $fn = $fn.'-'.$fna[strpos($this->fdd[$fd]['format'],'m')]; /*Month*/ $fn = $fn.'-'.$fna[strpos($this->fdd[$fd]['format'],'d')]; /*Day*/ } if ($val == '') { $val = ') VALUES (\''.addslashes($fn).'\''; } else { $val = $val.',\''.addslashes($fn).'\''; } } } $qry = $qry.$val.')'; // echo ''.$qry.'
'; $res = mysql_db_query ($this->db, $qry); echo ''.$qry.'
'; $res = mysql_db_query ($this->db, $qry); echo ''.$qry.'
'; $res = mysql_db_query ($this->db, $qry); echo '