I would like to create a dynamic table with fields like this.
table_name: book_list
book1(int(2)) book2(int(2)).... book44(int(2)
I have a php code like this.
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
for($i=1;$i<=44;$i++){
$sql = 'CREATE TABLE IF NOT EXISTS `book_list` (
book_'.$i. 'int(2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1';
mysql_select_db('book_db');
$retval = mysql_query( $sql, $conn );
}
?>
The above code needs some tweaks, that is to be done for generating the dynamic table.
Any help will be more appreciable.
Thanks, Kimz
PS: I know the MYSQL is getting depreciated but still this is for my client and he wants only mysql and not pdo or mysqli. looks crazy. but still
mysql_*functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which.