pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

jawaad private pastebin - collaborative debugging tool What's a private pastebin?


Posted by Jawaad on Thu 21 Aug 17:47
report abuse | download | new post

  1. <?php
  2. // UPLOAD CSV CUSTOM
  3. // Ver. 1.0
  4. // by Jawaad
  5. // zaibatsu@gmail.com
  6. // file: create table
  7.  
  8. if(!defined('jin')) { die('nice try..'); }
  9.  
  10. ?>
  11.  
  12. <form method="post">
  13. <br><br>
  14. <h2>Create Table</h2>
  15. Table Name: <input name="table_name">
  16. <input type="hidden" value="0" id="theValue" /><a href="javascript:;" onclick="addElement();">+ Add field</a>
  17. <p>
  18. <div id="myDiv"> </div>
  19.  
  20.  
  21. <input type="hidden" name="create_table" value="1">
  22. <input type="submit" name="submit" value="Create Table">
  23. </form>
  24.  
  25.  
  26. <?php
  27. if($_POST[create_table]=="1") {
  28.         //$kode = array($_POST[kode]);
  29.         $table_name = $_POST[table_name];
  30.         echo "Check <b>".$table_name."</b><br>";
  31.         //print_r($_POST[kode]);
  32.         if($table_name != "" && $_POST[kode] != "") {
  33.                 foreach ($_POST[kode] as $field_arr) {
  34.                         $field =  $_POST["field".$field_arr.""];
  35.                         $tipe = $_POST["tipe".$field_arr.""];
  36.                                  if($tipe == "TEXT") {$db_tipe = "varchar(255),";}
  37.                         elseif($tipe == "NUMERIC") {$db_tipe = "bigint(20),";}
  38.                         elseif($tipe == "NUMERIC-2-DECIMAL") {$db_tipe = "float(10,2),";}
  39.                         elseif($tipe == "LONG-TEXT") {$db_tipe = "text NOT NULL,";}
  40.                         elseif($tipe == "DATE") {$db_tipe = "date NOT NULL,";}
  41.                         elseif($tipe == "DATE-TIME") {$db_tipe = "datetime NOT NULL,";}
  42.                         $the_fields .= "`" . $field . "` " . $db_tipe . "\n";
  43.                 }
  44.                 $sql = "
  45.                                         CREATE TABLE IF NOT EXISTS `".$table_name."` (
  46.                                                 `id` bigint(20) NOT NULL auto_increment,
  47.                                                 ".$the_fields."
  48.                                                 PRIMARY KEY  (`id`)
  49.                                         ) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
  50.                 ";
  51.                 $ex = mysql_query($sql);
  52.                 if(!$ex) {
  53.                         echo "Sorry,... Error...<br>";
  54.                 } else {
  55.                         echo "Table  <b>".$table_name."</b> created.<br>";
  56.                 }
  57.         } else {
  58.                 echo "Sorry,... Error... Please fill the table name and the fields...<br>";
  59.         }
  60.         /*
  61.         echo "<pre>";
  62.         echo $sql;
  63.         echo "</pre>";
  64.         */
  65. }
  66. ?>

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post