Brother, I want to create a table in sql statement in php according to the parameters entered by the user
I want to create a table in the sql statement in php according to the parameters entered by the userFor example, I use $_GET[‘tablename’] to get the user’s input value, and I want to use the sql statement in the php file to create a name called The form of $_GET[‘tablename’], how to express the tablename herecreate table [tablename]? This sql statement is correctI use create table {. $_GET[‘tablename’ ]. } Can’t be realized? ——Solution——————- $sql = <<<SQLcreate table {$_GET[‘tablename’]}…SQL; ——Solution ——————–= <<<SQL is here documentheredoc syntax structure: <<<. An identifier is provided after the operator, followed by a newline. Next comes the string itself, ending with the previously defined identifier. <?php $cOntent= <<<FDIPZONE blog FDIPZONE; echo $content; ?> Reference: http://blog.csdn.net/fdipzone/article/details/24937669——Solution ———– ———That’s it. $sql =<<<SQLCREATE TABLE `{$_GET[‘tablename’]}` ( `id` int(10 ) unsigned NOT NULL auto_increment, `name` varchar(100) NOT NULL, `age` tinyint(4) unsigned NOT NULL, `addtime` datetime NOT NULL, PRIMARY KEY (`id`))SQL; mysql_query($sql) or die(mysql_error());