I'm trying to create a new table each day (each time my php script runs). I want to dynamically name these tables to help keep them organized. Here's what I've attempted so far with no luck:
$tableName = "CE" . date("Y.m.d");
// how do i use $tableName? to do this below dynamically?
$sql = "CREATE TABLE '$tableName'(
Date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
SKU VARCHAR(30) NOT NULL,
Title VARCHAR(125) NOT NULL,
Price FLOAT(8),
AZPrice FLOAT(8)
)";
$table = mysqli_query($connection, $sql);
//Same thing here below, insert into $tableName (dynamic name each day for new table)
$query = "INSERT INTO '$tableName'(Date,SKU,Title,Price,AZPrice) VALUES (CURDATE(), ?, ?, ?, ?)";
$stmt = mysqli_prepare($connection, $query);
mysqli_stmt_bind_param($stmt, "ssdd", $cleanedSku, $titlePlain, $priceFloat, $amazonPrice);
mysqli_stmt_execute($stmt);
How do I accomplish this? Thank you
ERRORS:
Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, bool given in C:\xampp\htdocs\demo\mysql\table.php on line 524
Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, bool given in C:\xampp\htdocs\demo\mysql\table.php on line 525
Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, bool given in C:\xampp\htdocs\demo\mysql\table.php on line 524
Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, bool given in C:\xampp\htdocs\demo\mysql\table.php on line 525
Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, bool given in C:\xampp\htdocs\demo\mysql\table.php on line 524
Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, bool given in C:\xampp\htdocs\demo\mysql\table.php on line 525