peuge Posted March 26, 2008 Share Posted March 26, 2008 I have called in an array of names entered in from a field in the previous php page. with these names I want to create a table in the database which has already been selected. The thing is these names could be different for each time I create a new table so I need to use these names from the array. Can I do this in the CREATE TABLE? $name_array = $_POST['fname']; $tname = $_POST['tname']; mysql_query("CREATE TABLE $tname( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), username VARCHAR(30), password VARCHAR(32))") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/98036-creating-table-from-array-of-strings/ Share on other sites More sharing options...
wildteen88 Posted March 26, 2008 Share Posted March 26, 2008 Why are you creating a new table to store a name? You should create just one table to store the names and insert each name as a new row Quote Link to comment https://forums.phpfreaks.com/topic/98036-creating-table-from-array-of-strings/#findComment-501602 Share on other sites More sharing options...
peuge Posted March 26, 2008 Author Share Posted March 26, 2008 Sorry you might have misunderstood. This is for adding a table to a database. The names are the names of the fields in the table and not the actual data to be stored in the table. Sorry didn't quite explain myself properly. Quote Link to comment https://forums.phpfreaks.com/topic/98036-creating-table-from-array-of-strings/#findComment-501605 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.