Potatis Posted July 29, 2007 Share Posted July 29, 2007 Hi all, Is it possible to create a table in a mysql database using a variable that originated from a form? I've searched the net for some info on this, but have had no success. Basically I want an admin to be able to set up a weekly round of football, and have a new table created for that round, based on teams set up each week using a form. The admin would enter the round number, and that would be the name of the new table. The teams listed in the form would simply be posted in the table after it is created with a game ID. So far, I only know how to create a table by running a sql query, but the admin won't know how to do that, I'd rather if it could be done using a form. Thanks for any help. Quote Link to comment Share on other sites More sharing options...
zq29 Posted July 29, 2007 Share Posted July 29, 2007 This could be done, you'd just dynamically create the SQL query and run it based on the form input: CREATE TABLE `$_POST[table_name]` ... But this is NOT recommended! I'd highly suggest you do some research on database design, you need to be able to store this data and recall it using a set database schema, you shouldn't be dynamically creating tables! Quote Link to comment Share on other sites More sharing options...
Potatis Posted July 29, 2007 Author Share Posted July 29, 2007 Thanks very much for the quick response. I pretty much gathered that it was not the done thing, since there is virtually no information about it. I'll think of a workaround. Thanks again. Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted July 29, 2007 Share Posted July 29, 2007 i often simply give a record multiple id's eg, if i was to have a message sectionin my site, then instead of habing a message table for every user, then i create the uniqu messsage id, the user-Id of who its to, and then the chain id, which is like reply... eg chain id "2" means its a reply to id "1". Hope this helps Quote Link to comment Share on other sites More sharing options...
Potatis Posted July 29, 2007 Author Share Posted July 29, 2007 Thanks PC Nerd, I hadn't thought about multiple ids. I'll have a think about how I can apply it to my game ids so I don't need to set up new tables. The alternative I am trying to avoid is having to set up a pre-made database with all the rounds already set up in tables. I'm sure It'll all become clearer when I study it some more. It's becoming obvious that I need to learn more about working with databases, beyond typical data retrieval. Quote Link to comment 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.