1. <h2>DKP</h2>
  2. <form method="POST" action="dkp.php">
  3. <p>Enter one or more queries separated by newlines:</p>
  4. </p>
  5. <table width = 1000>
  6. <tr>
  7. <th width = 300>Name</th><th>Item</th>
  8. </tr>
  9. </table>
  10. <textarea name="sites" rows = "7" cols = "120" wrap = "Off"></textarea>
  11. <p><input type="submit"> <input type="reset"></P>
  12. </form>
  13.  
  14. <?php
  15. function mysql_insert_array($table, $data) {
  16. foreach ($data as $field=>$value) {
  17. $fields[] = '`' . $field . '`';
  18. $values[] = "'" . mysql_real_escape_string($value) . "'";
  19.  
  20. }
  21. $field_list = join(',', $fields);
  22. $value_list = join(', ', $values);
  23.  
  24. $query = "INSERT INTO `" . $table . "` (" . $field_list . ") VALUES (" . $value_list . ")";
  25.  
  26. return $query;
  27. }
  28.  
  29. if(isset($_POST['raidData'])) {
  30. $raidInput = $_POST['raidData'];
  31. }
  32.  
  33. if(isset($raidInput)) {
  34. $newArr = explode("\r\n", $raidInput);
  35. foreach ($newArr as $key => $value) {
  36. if(is_null($value) || empty($value)) {
  37. unset($newArr[$key]);
  38. } else {
  39. $newArr[$key] = trim($value);
  40. }
  41. }
  42.  
  43. }
  44.  
  45.  
  46.  
  47. $nameArr = "";
  48. $itemArr = "";
  49.  
  50. foreach($newArr as $line) {
  51. $arr = explode("\t", $line);
  52. if($nameArr == "") {
  53. $nameArr = array($arr[0]);
  54. } else {
  55. $nameArr[] .= $arr[0];
  56. }
  57. if($itemArr == "") {
  58. $itemArr = array($arr[1]);
  59. } else {
  60. $itemArr[] .= $arr[1];
  61. }
  62.  
  63. }
  64.  
  65. mysql_connect;
  66. mysql_select_db;
  67.  
  68.  
  69.  
  70. mysql_insert_array($table, $nameArr);
  71.  
  72. mysql_insert_array($table, $itemArr);
  73.  
  74.  
  75.  
  76. ?>