为什么我的数据库中没有创建表?

我有一个php类,可以在数据库中自动创建表,然后将其拉出并显示在网站上。目标是为每个表存储不同的数据,但是当我调用创建表的函数时,数据库中仅创建了两个表,而不是全部三个。

我的期望:

  1. 当我运行html代码时,应使用三个表创建数据库。
  2. 当我将表格中的数据拖到网站上时,我应该会出错,因为我尚未在表格中存储任何数据。

我得到的是:

  1. 当我运行html代码时,仅使用两个表创建数据库(producttb和Featuredproducts2 -因此未创建Featuredproducts1)
  2. 尝试从表中提取数据时出现错误,这很奇怪,因为两个表的错误相同,但仅创建了一个表。
邮递区号
<?php
class CreateDb
{
        public $servername;
        public $username;
        public $password;
        public $dbname;
        public $tablename;
        public $tablenamefeatured1;
        public $tablenamefeatured2;
        public $con;


        // class constructor
    public function __construct(
        $dbname = "illustriousmarketing",
        $tablenamefeatured1 = "Featuredproducts1",
        $tablenamefeatured2 = "Featuredproducts2",
        $tablename = "Productdb",
        $servername = "localhost",
        $username = "root",
        $password = ""
    )
{
  $this->dbname = $dbname;
  $this->tablenamefeatured1 = $tablenamefeatured1;
  $this->tablenamefeatured2 = $tablenamefeatured2;
  $this->tablename = $tablename;
  $this->servername = $servername;
  $this->username = $username;
  $this->password = $password;

  // create connection
    $this->con = mysqli_connect($servername, $username, $password);

    // Check connection
    if (!$this->con){
        die("Connection failed : " . mysqli_connect_error());
    }

    // query
    $sql = "CREATE DATABASE IF NOT EXISTS $dbname";

    // execute query
    if(mysqli_query($this->con, $sql)){

        $this->con = mysqli_connect($servername, $username, $password, $dbname);

        // sql to create new table
        $sql = " CREATE TABLE IF NOT EXISTS $tablename
                        (id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
                         product_name VARCHAR (25) NOT NULL,
                         product_price FLOAT,
                         product_image VARCHAR (100)
                        );";

        $sql = " CREATE TABLE IF NOT EXISTS $tablenamefeatured1
                        (id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
                        product_name VARCHAR (25) NOT NULL,
                        product_price FLOAT,
                        product_image VARCHAR (100)
                        );";

        $sql = " CREATE TABLE IF NOT EXISTS $tablenamefeatured2
                        (id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
                        product_name VARCHAR (25) NOT NULL,
                        product_price FLOAT,
                        product_image VARCHAR (100)
                        );";

        if (!mysqli_query($this->con, $sql)){
            echo "Error creating table : " . mysqli_error($this->con);
        }

    }else{
        return false;
    }
}

// get product from the database
public function getData(){
    $sql = "SELECT * FROM $this->tablename";

    $result = mysqli_query($this->con, $sql);

    if(mysqli_num_rows($result) > 0){
        return $result;
    }
}

public function getFeatured1(){
    $sql = "SELECT * FROM $this->tablenamefeatured1";

    $result = mysqli_query($this->con, $sql);

    if(mysqli_num_rows($result) > 0){
        return $result;
    }
}

public function getFeatured2(){
    $sql = "SELECT * FROM $this->tablenamefeatured2";

    $result = mysqli_query($this->con, $sql);

    if(mysqli_num_rows($result) > 0){
        return $result;
    }
}

}

的HTML
<?php include('server.php'); 

require_once('php/CreateDB.php');

$database=new CreateDB("illustriousmarketing", "producttb");
$database=new CreateDB("illustriousmarketing", "Featuredproducts1");
$database=new CreateDB("illustriousmarketing", "Featuredproducts2");

div class="row">
    <?php
        $result = $database->getFeatured1();
        while($row = mysqli_fetch_assoc($result)){
            component($row['product_name'],$row['product_price'], $row['product_image']);
        }
    ?>
</div>
<div class="row">
    <?php
        $result = $database->getFeatured2();
        while($row = mysqli_fetch_assoc($result)){
            component($row['product_name'],$row['product_price'], $row['product_image']);
        }
    ?>
</div>

Only tables being created(Forget about loginform)