$controller = $_POST['controller']; $pieces = explode("~", $controller); $table = $pieces[0]; $qt = $pieces[1]; $return = $pieces[2]; $id = $pieces[3]; $hack = $pieces[4]; if ($qt == insert) $qt = 'INSERT INTO'; if ($qt == update) { $qt = 'UPDATE'; $end = "WHERE ID = '$id'"; } $pre = array_keys( $_POST ); //--------------------------------------------------------- mysql_query ("CREATE TABLE IF NOT EXISTS `$table` (`ID` INT NOT NULL AUTO_INCREMENT , PRIMARY KEY ( `id` ) )"); //--------------------------------------------------------- $count = count($pre); $count = $count - 2; $sql = "$qt $table SET"; for ($i=0; $i < $count; $i++) { $x=$i+1; $y = $_POST[$pre[$x]]; $d = $y; $d = htmlentities($d, ENT_QUOTES); mysql_query ("ALTER TABLE `$table` ADD `$pre[$x]` TEXT NOT NULL"); $sql .= " `$pre[$x]` = '$d',"; } $sql .= " ID = '$id' $end"; $query = mysql_query($sql) or die("$sql_error" . mysql_error()); //--------------------------------------------------------- [ TABLE TYPE HACK ] if (empty($hack)) { } else { $pieces = explode("/", $hack); $h0 = $pieces[0]; $h1 = $pieces[1]; $h2 = $pieces[2]; $h3 = $pieces[3]; $h4 = $pieces[4]; $h5 = $pieces[5]; mysql_query ("ALTER TABLE `$table` $h0 $h1 $h2 $h3 $h4 $h5"); $query = mysql_query($sql) or die("$sql_error" . mysql_error());