Php > Database Related
PHP form-class generator
PHP form-class generator "; echo "DB:
Table:
"; } else { if ( $ready ) { // print_r($_POST); ob_start(); echo ''."'".$_POST["represent$i"]."'"; } } echo '); ';//close the array() echo 'var $labels=array('; $n=0; for ( $i=0; $i < mysql_num_fields($fields); $i++ ) { if ( isset($_REQUEST["enable$i"]) ) { echo ($n++==0?'':',').($n % 3 ==1?' ':'')."'".mysql_field_name($fields,$i).'\'=>'."'".mysql_field_name($fields,$i)."'"; } } echo '); '; /* END INITIALIZATION ARRAYS */ echo ' function generateForm ( $source="" ) { $fields = array_keys($this->renderStyle); if ( $source == \'request\' || $source == \'input\' || $source ==\'form\' ) { foreach ( $fields as $n=>$f) $$f=$_REQUEST[$f]; } else if ( !empty($source) ) { //$source should be a mySQL string $query = mysql_query($source); $data = mysql_fetch_array($query); //Begin conversion from DB row to our form variables foreach ( $fields as $n=>$f) $$f=$data[$f]; } echo "
"; echo "
"; //Time to render the form itself, now that we have the variables; foreach ( $fields as $n=>$f ) { echo "
".$this->labels[$f]."
"; switch($this->renderStyle[$f]) { case \'textarea\': echo "
".$$f.""; break; case \'input\': default: echo "
"; } echo "
"; } echo "
"; } function verifyForm () { foreach ( $this->renderStyle as $f=>$r) if ( empty($_REQUEST[$f]) ) return false; //At least one empty element return true; } function getSQL_setClause () { $c=0; $ret=""; foreach ($this->renderStyle as $f=>$r) { if ( $c++ > 0 ) $ret .= ","; $ret .= "$f=\'$_REQUEST[$f]\'"; } return $ret; } function getSQL_updateRow ( $whereClause) { $sql = "update '.$table.' set " .$this->getSQL_setClause() . " where $whereClause"; return $sql; } function getSQL_insertRow () { $sql = "insert into '.$table.' set " . $this->getSQL_setClause(); return $sql; } } //End Class ?>'; $output=ob_get_contents(); ob_end_clean(); //echo "
$output
"; highlight_string($output); } else { echo "
"; echo "
"; echo "
"; $fields = mysql_list_fields($db,$table); echo "
"; for ( $i=0; $i < mysql_num_fields($fields); $i++ ) { switch ( mysql_field_type($fields, $i) ) { case 'int': case 'bigint': case 'mediumint': $choices = array("input"); break; case 'varchar': $choices = array("input"); break; case 'blob': case 'text': $choices = array("textarea", "input");break; default: $choices=array("input"); } echo "
"; echo "
"; echo "
".mysql_field_name($fields, $i) . "-
" . mysql_field_type($fields,$i) . "
" . mysql_field_len($fields,$i) ." (" . mysql_field_flags($fields,$i).")" . "
\n"; foreach ( $choices as $n=>$k ) { echo "
$k
"; } echo "
"; } echo "
"; echo "
"; } } function ob_pre ( $buffer ) { return "
".$buffer."
"; } ?>
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage