CoreyR Posted June 23, 2007 Share Posted June 23, 2007 I'm trying to create tables from username, is this possible? I would think it was, but I know I have the syntax wrong. Thanks for helping. $query = 'CREATE TABLE "$username"( '. 'cid INT NOT NULL AUTO_INCREMENT, '. 'cname VARCHAR(20) NOT NULL, '. 'cemail VARCHAR(50) NOT NULL, '. 'csubject VARCHAR(30) NOT NULL, '. 'cmessage TEXT NOT NULL, '. 'PRIMARY KEY(cid))'; Link to comment https://forums.phpfreaks.com/topic/56879-solved-is-this-possible-create-a-table-from-a-variable/ Share on other sites More sharing options...
pocobueno1388 Posted June 23, 2007 Share Posted June 23, 2007 I don't see why it wouldn't be possible... Here is a website that will show you the correct syntax: http://www.w3schools.com/php/php_mysql_create.asp Link to comment https://forums.phpfreaks.com/topic/56879-solved-is-this-possible-create-a-table-from-a-variable/#findComment-281017 Share on other sites More sharing options...
CoreyR Posted June 23, 2007 Author Share Posted June 23, 2007 Ya, I've been there. That only shows how to create a database and a table, but not using a variable. Thanks Link to comment https://forums.phpfreaks.com/topic/56879-solved-is-this-possible-create-a-table-from-a-variable/#findComment-281023 Share on other sites More sharing options...
pocobueno1388 Posted June 23, 2007 Share Posted June 23, 2007 Just replace the table name with the variable.... CREATE TABLE $username ( column_name1 data_type, column_name2 data_type, column_name3 data_type, ....... ) Link to comment https://forums.phpfreaks.com/topic/56879-solved-is-this-possible-create-a-table-from-a-variable/#findComment-281028 Share on other sites More sharing options...
CoreyR Posted June 23, 2007 Author Share Posted June 23, 2007 Perfect, thank you. I tried that earlier but I believe I had a syntax error which wasn't allowing me to create the table with or without using the variable. Thanks for the help guys! Corey R. Link to comment https://forums.phpfreaks.com/topic/56879-solved-is-this-possible-create-a-table-from-a-variable/#findComment-281043 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.