test.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. $servername = "127.0.0.1";
  3. $username = "bjedu";
  4. $password = "123456";
  5. $dbname = "bjedu";
  6. // 创建连接
  7. $conn = new mysqli($servername, $username, $password, $dbname);
  8. // 检测连接
  9. if ($conn->connect_error) {
  10. die("连接失败: " . $conn->connect_error);
  11. }
  12. //`shcool_id` int(11) DEFAULT NULL,
  13. // 使用 sql 创建数据表
  14. $sql = "CREATE TABLE `jijiao_zhongzhi_school` (
  15. `ids` int(11) unsigned NOT NULL AUTO_INCREMENT,
  16. ";
  17. $a = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
  18. //$a = ['B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
  19. $b = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
  20. foreach ($a as &$g){
  21. $sql .= " `$g` varchar(255) DEFAULT NULL,";
  22. }
  23. foreach ($a as &$v){
  24. /*if ($v>'A'){
  25. break;
  26. }*/
  27. foreach ($b as &$c){
  28. $name = $v.$c;
  29. // if ($name>'JV'){
  30. // break;
  31. // }
  32. $sql .= " `$name` text DEFAULT NULL,";
  33. }
  34. }
  35. $sql .= "PRIMARY KEY (`ids`)
  36. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='中职学校';";
  37. if ($conn->query($sql) === TRUE) {
  38. echo "Table created successfully";
  39. } else {
  40. echo "创建数据表错误: " . $conn->error;
  41. }
  42. $conn->close();
  43. ?>