0) { while ($row = mysql_fetch_assoc($result)) { if(count($row)>0){ foreach($row as $k_field=>$v_field){ if($k_field=="Field"){ $arr_table_field[]=$v_field; //echo $v_field."
"; } if($k_field=="Type"){ // echo $v_field."
"; $arr_table_type[]=$v_field; } } } // print_r($row); } if($act_update==1){ $str_update="UPDATE $table SET "."
"; $num_field=count($arr_table_field); $i_field=0; if($num_field>0){ foreach($arr_table_field as $k_field=>$v_field){ $i_field++; if(preg_match('/^int/', $arr_table_type[$k_field], $matches, PREG_OFFSET_CAPTURE)){ $type="trim(\$".$g_type.")"; }else if(preg_match('/^varchar/', $arr_table_type[$k_field], $matches, PREG_OFFSET_CAPTURE)){ $type="addslashes(\$".$g_type.")"; }else if(preg_match('/^tinyint/', $arr_table_type[$k_field], $matches, PREG_OFFSET_CAPTURE)){ $type="trim(\$".$g_type.")"; }else if(preg_match('/^datetime/', $arr_table_type[$k_field], $matches, PREG_OFFSET_CAPTURE)){ $type="date('Y-m-d H:i:s')"; }else{ $type="\$$g_type"; } if($i_field==$num_field){ $str_update.=" ".$v_field."='\".$type.\"'"."
"; }else{ $str_update.=" ".$v_field."='\".$type.\"',"."
"; } } $str_update.="WHERE $where='\".\$$g_type.\"'"."
"; } echo $str_update; } if($act_insert==1){ echo "

"; $str_insert="INSERT INTO $table (
"; $num_field=count($arr_table_field); $i_field=0; if($num_field>0){ $str_insert_field=""; $str_insert_value=""; foreach($arr_table_field as $k_field=>$v_field){ $i_field++; if(preg_match('/^int/', $arr_table_type[$k_field], $matches, PREG_OFFSET_CAPTURE)){ $type="trim(\$".$g_type2.")"; }else if(preg_match('/^varchar/', $arr_table_type[$k_field], $matches, PREG_OFFSET_CAPTURE)){ $type="addslashes(\$".$g_type2.")"; }else if(preg_match('/^tinyint/', $arr_table_type[$k_field], $matches, PREG_OFFSET_CAPTURE)){ $type="trim(\$".$g_type2.")"; }else if(preg_match('/^datetime/', $arr_table_type[$k_field], $matches, PREG_OFFSET_CAPTURE)){ $type="date('Y-m-d H:i:s')"; }else{ $type="\$$g_type2"; } if($i_field==$num_field){ $str_insert_field.=" ".$v_field."
"; $str_insert_value.=" '\".$type.\"'"."
"; }else{ $str_insert_field.=" ".$v_field.",
"; $str_insert_value.=" '\".$type.\"',"."
"; } } $str_insert.=$str_insert_field; $str_insert.=") VALUES (
"; $str_insert.=$str_insert_value; $str_insert.=")
"; } echo $str_insert; } if($act_delete==1){ echo "

"; $str_delete="DELETE FROM $table WHERE $where='\".\$$g_type3.\"'"."
"; echo $str_delete; } // print_r($arr_table_type); } } ?>