12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- $servername = "127.0.0.1";
- $username = "bjedu";
- $password = "123456";
- $dbname = "bjedu";
- // 创建连接
- $conn = new mysqli($servername, $username, $password, $dbname);
- // 检测连接
- if ($conn->connect_error) {
- die("连接失败: " . $conn->connect_error);
- }
- //`shcool_id` int(11) DEFAULT NULL,
- // 使用 sql 创建数据表
- $sql = "CREATE TABLE `jijiao_zhongzhi_school` (
- `ids` int(11) unsigned NOT NULL AUTO_INCREMENT,
-
- ";
- $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'];
- //$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'];
- $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'];
- foreach ($a as &$g){
- $sql .= " `$g` varchar(255) DEFAULT NULL,";
- }
- foreach ($a as &$v){
- /*if ($v>'A'){
- break;
- }*/
- foreach ($b as &$c){
- $name = $v.$c;
- // if ($name>'JV'){
- // break;
- // }
- $sql .= " `$name` text DEFAULT NULL,";
- }
- }
- $sql .= "PRIMARY KEY (`ids`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='中职学校';";
- if ($conn->query($sql) === TRUE) {
- echo "Table created successfully";
- } else {
- echo "创建数据表错误: " . $conn->error;
- }
- $conn->close();
- ?>
|