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"; } else { echo ''."\n"; } } function display_add_record () { for ($k = 0; $k < $this->num_fds; $k++) { if ( $this->displayed() ) { echo ' '."\n"; echo ' '.$this->fdd[$this->fds[$k]]['name'].''."\n"; if (isset ($this->fdd[$this->fds[$k]]['values']['table']) and isset ($this->fdd[$this->fds[$k]]['values']['column']) and isset ($this->fdd[$this->fds[$k]]['values']['description'])) { echo ' '."\n"; } elseif (isset ($this->fdd[$this->fds[$k]]['values']['table']) and isset ($this->fdd[$this->fds[$k]]['values']['column'])) { echo ' '."\n"; } elseif (isset ($this->fdd[$this->fds[$k]]['values'])) { echo ' '."\n"; } elseif (isset ($this->fdd[$this->fds[$k]]['textarea'])) { echo ' '."\n"; } else { /* Simple edit box required */ echo ' '."\n"; } /* if elseif else */ echo ' '."\n"; } } /* for k < this->num_fds */ } function display_change_delete_record () { /* for delete or change: SQL SELECT to retrieve the selected record */ $qry = $this->create_column_list ($this->tb, $this->fdd); if (!in_array ($this->key, $this->fds)) { $qry = $qry.','.$this->fully_qualified_name ($this->tb, $this->fdd, $this->key); } $qry = $qry.$this->create_from_clause ($this->tb, $this->fdd); $qry_select = $this->create_where_clause ($this->tb, $this->fdd); if ($qry_select == '') { $kwd = ' WHERE '; } else { $kwd = ' AND '; } $qry = $qry.$qry_select.$kwd.'('.$this->fully_qualified_name($this->tb,$this->fdd,$this->key).' = '.$this->key_delim.$this->rec.$this->key_delim.')'; // echo '

'.$qry.'

'; $res = mysql_db_query ($this->db, $qry); if ($row = mysql_fetch_array ($res)) { for ($k = 0; $k < $this->num_fds; $k++) { if ($this->change_operation ()) { if ( $this->displayed() ) { echo ' '."\n"; echo ' '.$this->fdd[$this->fds[$k]]['name'].''."\n"; $this->display_change_field ($row, $k); echo ' '."\n"; } } if ($this->delete_operation ()) { if ( $this->displayed() ) { echo ' '."\n"; echo ' '.$this->fdd[$this->fds[$k]]['name'].''."\n"; $this->display_delete_field ($row, $k); echo ' '."\n"; } } } /* for */ } /* if row */ } function display_change_field ($row, $k) { if (isset ($this->fdd[$this->fds[$k]]['values']['table']) and isset ($this->fdd[$this->fds[$k]]['values']['column']) and isset ($this->fdd[$this->fds[$k]]['values']['description'])) { echo ' '."\n"; } elseif (isset ($this->fdd[$this->fds[$k]]['values']['table']) and isset ($this->fdd[$this->fds[$k]]['values']['column'])) { echo ' '."\n"; } elseif (isset ($this->fdd[$this->fds[$k]]['values'])) { echo ' '."\n"; } elseif (isset ($this->fdd[$this->fds[$k]]['textarea'])) { echo ' '."\n"; } else { echo ' '."\n"; } /* if elseif else */ } function display_delete_field ($row, $k) { if ($row[$k] == '') { echo '  '."\n"; } else { echo ' '.nl2br(htmlentities($row[$k])).''."\n"; } } function web2plain($x) { if (isset($x)) { if (is_array($x)) { for ($n=0; $nweb2plain($x[$n]); } } else { $x = rawurldecode($x); } } return $x; } function plain2web($x) { if (isset($x)) { if (is_array($x)) { for ($n=0; $nplain2web($x[$n]); } } else { $x = rawurlencode($x); } } return $x; } function get_http_get_var_by_name ($name) { global $HTTP_GET_VARS; if (is_array($HTTP_GET_VARS)) $v = $HTTP_GET_VARS[$name]; /* $v could be an array if we allowed bidimensional form fields */ return $v; } function get_http_post_var_by_name ($name) { global $HTTP_POST_VARS; if (is_array($HTTP_POST_VARS)) $v = $HTTP_POST_VARS[$name]; /* $v could be an array if we allowed bidimensional form fields */ return $v; } function print_get_vars ($miss = "No GET variables found") /*debug only*/ { global $HTTP_GET_VARS; /* we parse form GET variables */ if (is_array($HTTP_GET_VARS)) { echo "

Variables per GET "; foreach ($HTTP_GET_VARS as $k => $v) { if (is_array($v)) { foreach ($v as $akey => $aval) { // $HTTP_GET_VARS[$k][$akey] = strip_tags($aval); // $$k[$akey] = strip_tags($aval); echo "$k\[$akey\]=$aval "; } } else { // $HTTP_GET_VARS[$k] = strip_tags($val); // $$k = strip_tags($val); echo "$k=$v "; } } echo "

"; } else { echo "

"; echo "$miss"; echo "

"; } } function print_post_vars ($miss = "No POST variables found") /*debug only*/ { global $HTTP_POST_VARS; /* we parse form POST variables */ if (is_array($HTTP_POST_VARS)) { echo "

Variables per POST "; foreach ($HTTP_POST_VARS as $k => $v) { if (is_array($v)) { foreach ($v as $akey => $aval) { // $HTTP_POST_VARS[$k][$akey] = strip_tags($aval); // $$k[$akey] = strip_tags($aval); echo "$k\[$akey\]=$aval "; } } else { // $HTTP_POST_VARS[$k] = strip_tags($val); // $$k = strip_tags($val); echo "$k=$v "; } } echo "

"; } else { echo "

"; echo "$miss"; echo "

"; } } function print_vars ($miss = "Current instance variables") /*debug only*/ { echo "$miss "; echo "page_name=".$this->page_name." "; echo "hn=".$this->hn." "; echo "un=".$this->un." "; echo "pw=".$this->pw." "; echo "db=".$this->db." "; echo "tb=".$this->tb." "; echo "key=".$this->key." "; echo "key_type=".$this->key_type." "; echo "inc=".$this->inc." "; echo "options=".$this->options." "; echo "fdd=".$this->fdd." "; echo "fl=".$this->fl." "; echo "fm=".$this->fm." "; echo "sfn=".$this->sfn." "; echo "qfn=".$this->qfn." "; echo "sw=".$this->sw." "; echo "rec=".$this->rec." "; echo "prev=".$this->prev." "; echo "next=".$this->next." "; echo "saveadd=".$this->saveadd." "; echo "moreadd=".$this->moreadd." "; echo "savechange=".$this->savechange." "; echo "savedelete=".$this->savedelete." "; echo "operation=".$this->operation." "; echo "\n"; } function list_table () { /* ====================================================================== Pass 1 and Pass 3: display the MySQL table in a scrolling window on the screen. ====================================================================== */ if ($this->listit) { /* Process any navigation buttons */ if (!isset ($this->fm)) { $this->fm = 0; } if ($this->prev == 'Prev') { $this->fm = $this->fm - $this->inc; if ($this->fm < 0) { $this->fm = 0; } } if ($this->next == 'Next') { $this->fm = $this->fm + $this->inc; } /* Process filters */ if (!isset ($this->fl)) { $this->fl = 0; } /* by default, no filters */ /* filter switch has been pressed */ if (isset ($this->sw)) { if ($this->sw == 'v') { $this->fl = 1; } if ($this->sw == '^') { $this->fl = 0; } } /* If user is allowed to Change/Delete records, we need an extra column to allow users to select a record */ $select_recs = (($this->change_enabled () or $this->delete_enabled ()) and ($this->key != '')); /* Default is to sort on first field */ if ($this->sfn == '' and ! ($this->initial_sort_suppressed()) ) { $this->sfn = 0; } /* Display the MySQL table in an HTML table */ echo ''."\n"; echo ' '."\n"; echo ' '."\n"; /* if the filter input boxes are not displayed, we need to preserve the filter */ if (!$this->fl) { for ($k = 0; $k < $this->num_fds; $k++) { $l = 'qf'.$k; global $$l; $m = $this->web2plain($$l); if (isset ($m)) { if (is_array($m)) /*multiple selection has been used*/ { if (!in_array('*',$m)) /*one '*' in a multiple selection is all you need*/ { for ($n=0; $nplain2web($m[$n]) != '') { echo ' '."\n"; } } } } else { if ($this->plain2web($m) != '') { $this->qfn = $this->qfn.'&qf'.$k.'='.$this->plain2web($m); echo ' '."\n"; } } } } } /* Set up the URLs which allow sorting by clicking on column headings */ $prev_qfn = $this->qfn; $this->qfn = ''; for ($k = 0; $k < $this->num_fds; $k++) { $l = 'qf'.$k; global $$l; $m = $this->web2plain($$l); if (isset ($m)) { if (is_array($m)) /*multiple selection has been used*/ { if (!in_array('*',$m)) /*one '*' in a multiple selection is all you need*/ { for ($n=0; $nplain2web($m[$n]) != '') { $this->qfn = $this->qfn.'&qf'.$k.'['.$n.']='.$this->plain2web($m[$n]); } } } } else { if ($this->plain2web($m)!='') { $this->qfn = $this->qfn.'&qf'.$k.'='.$this->plain2web($m); } } } } echo ' '."\n"; /* if sort sequence has changed, restart listing */ if ($this->qfn != $prev_qfn) { // echo '

'.$this->qfn.'<>'.$prev_qfn.' Reset fm

'; $this->fm = 0; } /* descending sort order is flagged by a minus sign */ if (isset ($this->sfn)) { $sort_asc = (substr ($this->sfn, 0, 1) != '-'); if (!$sort_asc) { $this->sfn = substr ($this->sfn, 1); } } echo ' '."\n"; echo ' '."\n"; echo ' '."\n"; /* we need an initial column if we have filters, or Changes or Deletes enabled */ if ($this->filter_enabled () or $select_recs) { if ($this->filter_enabled ()) { if ($this->fl) { echo ' '."\n"; } else { echo ' '."\n"; } } else { echo ' '."\n"; } } for ($k = 0; $k < $this->num_fds; $k++) { $fd = $this->fds[$k]; //bro1 //we do not want to display fields that have listview property set to false // if ($this->fdd[$fd]["listview"] == true or !isset ($this->fdd[$fd]["listview"])) { if (stristr($this->fdd[$fd]['options'],'L') or !isset ($this->fdd[$fd]['options'])) { $fdn = $this->fdd[$fd]['name']; if (isset ($this->fdd[$fd]['width'])) { $w = ' width="'.$this->fdd[$fd]['width'].'"'; } else { $w = ''; } if ($this->fdd[$fd]['sort']) { /* clicking on the current sort field reverses the sort order */ if (($k == $this->sfn) and ($sort_asc)) { echo ' '.$fdn.''."\n";; } else { echo ' '.$fdn.''."\n";; } } else { echo ' '.$fdn.''."\n"; } } /* if */ } /* for */ echo ' '."\n"; /* Prepare the SQL Query from the data definition file */ $qry = $this->create_column_list ($this->tb, $this->fdd); /* Even if the key field isn't displayed, we still need its value */ if ($select_recs) { if (!in_array ($this->key, $this->fds)) { $qry = $qry.','.$this->fully_qualified_name ($this->tb, $this->fdd, $this->key); }; } $qry = $qry.$this->create_from_clause ($this->tb, $this->fdd); $qry_select = $this->create_where_clause ($this->tb, $this->fdd); if ($qry_select == '') { $kwd = ' WHERE '; } else { $kwd = ' AND '; } for ($k = 0; $k < $this->num_fds; $k++) { $l = 'qf'.$k; global $$l; $m = $this->web2plain($$l); if (isset ($m)) { if (is_array($m)) /*multiple selection has been used*/ { if (!in_array('*',$m)) /*one '*' in a multiple selection is all you need*/ { for ($n=0; $nfully_qualified_name($this->tb,$this->fdd,$this->fds[$k]).$afilter.') '; $kwd = ' AND '; } } else { $afilter = $m; if (($afilter != '') AND ($afilter != '*')) { if (strstr ($afilter, '*')) { $afilter = str_replace ('*', '%', $afilter); $qry_select = $qry_select.$kwd.' ('.$this->fully_qualified_name($this->tb,$this->fdd,$this->fds[$k]).' like \''.$afilter.'\') '; } else { $qry_select = $qry_select.$kwd.' ('.$this->fully_qualified_name($this->tb,$this->fdd,$this->fds[$k]).' = \''.$afilter.'\') '; } $kwd = ' AND '; } } } /* if */ } /* for */ $qry = $qry.$qry_select; if (isset ($this->sfn)) { $qry = $qry.' ORDER BY '.$this->fully_qualified_name ($this->tb, $this->fdd, $this->fds[$this->sfn]); if (!$sort_asc) { $qry = $qry.' DESC'; } } $to = $this->fm + $this->inc; $qry = $qry.' LIMIT '.$this->fm.','.$this->inc; /* Each row of the HTML table is one record from the SQL Query */ // echo ''."\n"; $res = mysql_db_query ($this->db, $qry); $first = true; $eot = $this->inc; while ($row = mysql_fetch_array ($res)) { echo ' '."\n"; /* Draw the filter and fill it with any data typed in last pass and stored in the array parameter keyword 'filter'. Prepare the SQL WHERE clause. */ if ($first AND $this->fl) { echo ' '."\n"; for ($k = 0; $k < $this->num_fds; $k++) { $fd = $this->fds[$k]; $l = 'qf'.$k; global $$l; $m = $this->web2plain($$l); //bro1 //do not display filter for the items that are not shown in the listview // if ($this->fdd[$fd]["listview"] == true or !isset ($this->fdd[$fd]["listview"])) { if (stristr($this->fdd[$fd]['options'],'L') or !isset ($this->fdd[$fd]['options'])) { if ($this->fdd[$fd]['select'] == 'D' or $this->fdd[$fd]['select'] == 'M') { if (isset ($this->fdd[$this->fds[$k]]['values']['table']) and isset ($this->fdd[$this->fds[$k]]['values']['column']) and isset ($this->fdd[$this->fds[$k]]['values']['description'])) { $x = $this->set_values_from_table ($this->db, $this->tb.','.$this->fdd[$this->fds[$k]]['values']['table'], $this->fdd[$this->fds[$k]]['values']['table'].'.'.$this->fdd[$this->fds[$k]]['values']['column'], $this->fdd[$this->fds[$k]]['values']['table'].'.'.$this->fdd[$this->fds[$k]]['values']['description'], ' WHERE ('.$this->fdd[$this->fds[$k]]['values']['table'].'.'.$this->fdd[$this->fds[$k]]['values']['column'].' = '.$this->tb.'.'.$fd.')'); } else { $x = $this->set_values_from_table ($this->db, $this->tb, $fd); } // multiple fields processing - default size is 2 and array required for values if (!isset($this->multiple)) {$this->multiple=2;} if ($this->fdd[$fd]['select'] == 'M') { $a = ' multiple size="'.$this->multiple.'"'; } else { $a=''; } echo ' '."\n"; } elseif ($this->fdd[$fd]['select'] == 'T') { echo ' '."\n"; } else { echo ' '."\n"; } /* if elseif else */ } /* end if bro1 */ } /* for */ echo ' '."\n"; echo ' '."\n"; } /* if first and fl */ if ($select_recs) { if ($first) { echo ' '."\n"; } else { echo ' '."\n"; } } elseif ($this->filter_enabled ()) { echo ' '."\n"; } $first = false; for ($k = 0; $k < $this->num_fds; $k++) { // bro1 // we do not want to display fields that have their listview property set to false $fd = $this->fds[$k]; // if ($this->fdd[$fd]["listview"] == true or !isset($this->fdd[$fd]["listview"])) { if (stristr($this->fdd[$fd]['options'],'L') or !isset($this->fdd[$fd]['options'])) { if ((trim ($row[$k]) == '') or ($row[$k] == 'NULL')) { echo ' '."\n"; } else { $row[$k] = nl2br (htmlentities ($row[$k])); /* Make clickable items clickable */ if (!isset($this->fdd[$this->fds[$k]]['URL'])) { echo ' '."\n"; } else { echo ' '."\n"; } } /* if else */ } /* if */ } /* for */ echo ' '."\n"; --$eot; } /* while */ echo '
 
'.$qry.'
'."\n"; if (( is_array($m) and in_array('*',$m)) or ($m == '*')) { echo ' '."\n"; } else { echo ' '."\n"; } for ($j = 0; $j < count ($x['option']); $j++) { if (is_array($m)) { if (in_array($x['value'][$j],$m)) { echo ' '."\n"; } else { echo ' '."\n"; } } else { if ($x['value'][$j] == $m) { echo ' '."\n"; } else { echo ' '."\n"; } } } /* for */ echo '  
  '.$row[$k].''.$row[$k].'
'."\n"; /* note that \n \n"; if ($this->fm > 0) { echo ' '."\n"; } else { echo ' '."\n"; } if ($this->add_enabled ()) { echo ' '."\n"; } if ($first) { if ($this->change_enabled ()) { echo ' '."\n"; } if ($this->delete_enabled ()) { echo ' '."\n"; } } else { if ($this->change_enabled ()) { echo ' '."\n"; } if ($this->delete_enabled ()) { echo ' '."\n"; } } /* if else */ // if ($this->fl) { // echo ' '."\n"; // } if ($eot == 0) { echo ' '."\n"; } else { echo ' '."\n"; } /* Display the current page and the total pages */ echo ' '."\n"; $total = 0; $qry = 'select count(*) as nbrecno '.$this->create_from_clause($this->tb,$this->fdd).$qry_select; // echo('

'.$qry.'

'); $res = mysql_db_query($this->db, $qry); while ($row = mysql_fetch_row($res)) { $values[] = $row[0]; } $total = $values[0]; echo ' '."\n"; echo ' '."\n"; echo '
  Page: '.(($this->fm/$this->inc)+1).' / '.Ceil($total/$this->inc).' Records: '.$total.'
'."\n"; echo ''."\n"; } /* if this->listit */ } function display_record () { /* ====================================================================== Pass 2: display an input/edit/confirmation screen if the user has selected an editing button on Pass 1 through this page ====================================================================== */ $this->listit = true; if ($this->add_operation() or $this->change_operation() or $this->delete_operation()) { /* we don't list when we manipulate a single record */ $this->listit = false; $this->create_javascripts (); echo ''."\n"; echo ' '."\n"; echo ' '."\n"; echo ' '."\n"; echo ' '."\n"; /* preserve the values of any filter fields qf0..qfn for Pass 3 */ for ($k = 0; $k < $this->num_fds; $k++) { $l = 'qf'.$k; global $$l; $m = $this->web2plain($$l); if (isset ($m)) { if (is_array($m)) /*multiple selection has been used*/ { if (!in_array('*',$m)) /*one '*' in a multiple selection is all you need*/ { for ($n=0; $nplain2web($m[$n]) != '') { echo ' '."\n"; } } } } else { if ($this->plain2web($m) != '') { $this->qfn = $this->qfn.'&qf'.$k.'='.$m; echo ' '."\n"; } } } } echo ' '."\n"; if ($this->add_operation ()) { $this->display_add_record (); } else { $this->display_change_delete_record (); } echo '
'."\n"; echo '
'."\n"; if ($this->add_operation ()) { echo ''."\n"; echo ''."\n"; echo ''."\n"; } if ($this->change_operation ()) { echo ''."\n"; echo ''."\n"; } if ($this->delete_operation ()) { echo ''."\n"; echo ''."\n"; } 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 '
'.mysql_affected_rows ().' record added
'."\n"; } /* if this->saveadd */ if ($this->savechange == 'Save') { /* we fill the record field names 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 = 'UPDATE '.$this->tb.' SET `'.$this->fds[$k].'`=\''.addslashes($fn).'\''; } else { $qry = $qry.',`'.$this->fds[$k].'`=\''.addslashes($fn).'\''; } } } $qry = $qry.' WHERE ('.$this->key.' = '.$this->key_delim.$this->rec.$this->key_delim.')'; // echo '

'.$qry.'

'; $res = mysql_db_query ($this->db, $qry); echo '
'.mysql_affected_rows ().' record changed
'."\n"; } /* if this->savechange */ if ($this->savedelete == 'Delete') { $qry = 'DELETE FROM '.$this->tb.' WHERE (`'.$this->key.'` = '.$this->key_delim.$this->rec.$this->key_delim.')'; $res = mysql_db_query ($this->db, $qry); echo '
'.mysql_affected_rows ().' record deleted
'."\n"; } /* if this->savedelete */ } function execute() { set_magic_quotes_runtime(0); /*let's do it ourselves ... it's safer */ // debug code - uncomment to enable // phpinfo(); // $this->print_get_vars (); // $this->print_post_vars (); // $this->print_vars (); if ($this->key_type == 'string' || $this->key_type == 'blob' || $this->key_type == 'date' || $this->key_type == 'time') { $this->key_delim = '"'; } else { $this->key_delim = ''; } $dbl = @mysql_pconnect ($this->hn, $this->un, $this->pw) or die ('

Could not connect to MySQL

'."\n"); if (!isset ($this->db)) { die ('

No Database defined

\n\n'."\n"); } if (!isset ($this->tb)) { die ('

No Table defined

\n\n'."\n"); } $this->update_record (); $this->display_record (); $this->list_table (); } function PHPMyEdit($hn, $un, $pw, $db, $tb, $key, $key_type, $inc, $options, $multiple, $fdd) { /* we instance class variables */ $this->hn = $hn; $this->un = $un; $this->pw = $pw; $this->db = $db; $this->tb = $tb; $this->key = $key; $this->key_type = $key_type; $this->inc = $inc; $this->options = $options; $this->multiple = $multiple; $this->fdd = $fdd; /* we need the URL to post forms */ global $HTTP_SERVER_VARS; $this->page_name =basename($HTTP_SERVER_VARS["PHP_SELF"]); /* we need some form variables all around */ global $operation, $apply, $fl, $fm, $sfn, $qfn, $sw, $rec, $prev, $next, $saveadd, $moreadd, $savechange, $savedelete; $this->operation = $operation; $this->apply = $apply; $this->fl = $fl; $this->fm = $fm; $this->sfn = $sfn; $this->qfn = $qfn; $this->sw = $sw; $this->rec = $rec; $this->prev = $prev; $this->next = $next; $this->saveadd = $saveadd; $this->moreadd = $moreadd; $this->savechange = $savechange; $this->savedelete = $savedelete; /* we keep SQL Field Names and number of fields */ foreach ($this->fdd as $akey => $aval) { $this->fds[] = $akey; } $this->num_fds = sizeof ($this->fds); } } // End of class ?>