Jump to content

Create tables on register...


batstanggt

Recommended Posts

hey guys i have a website im working on and i would like to have 5 separate tables be created in my database for each user who registers. Is it possible to use a variable taken from the register form to use in the table name? Ie...

CREATE TABLE ($id)table_name
(
column_name1 data_type,
column_name2 data_type,
column_name3 data_type,
....
) 

$id is obviously the variable. I dont know if that is te correct syntax but if someone could tell me how to do this that would be great. So basically the name of the table created from that would be for example 1table_name, 2table_name, 3table_name etc.... Then would I just put 5 create table statements in my registration.php page one right after another so that the tables are created as the registration is completed? I have only ever used phpmyadmin so far to create tables so im not sure about using code to create a table let alone 5 at one time hahaha. Thanks guys.

-SB

 

Link to comment
Share on other sites

No, you really do not want to do that; there is absolutely no reason to add tables to a database just because a user registers, and you'll be creating a nightmare for yourself in the future. You need to use a normalized database structure, not attempt to force a relational database to mimic a spreadsheet.

Link to comment
Share on other sites

Ahhh I see. Thanks pikachu i think you are right though something did seem awkward about trying to use a relational database structure (forced if you will). Now I did follow your link but would you mind explaining ..."You need to use a normalized database structure, not attempt to force a relational database to mimic a spreadsheet". And I'm not really sure how that would create a nightmare for myself would you mind also explaining that? Im not challenging your opinion im just curious to learnin why.

-SB

Link to comment
Share on other sites

If you have even a small amount of users register, let's say 5000, you now have 25,000 tables in the DB. What happens when you need to select a common piece of data, like the date the users joined perhaps, from all the tables and compare it?

Link to comment
Share on other sites

LMAO but what if each user is the only one updating this database does that make any difference. I really really do appreciate your advice like i say dont take that as a challenge of ur solution but more so curious if the fact that i wont be modifying anything has any bearing on the situation what so ever. Or just bad idea no matter what and why...please. Im of the mind that if you fish for a man he eats for a week, if you teach him to fish he eats for life hahah. Thanks guys.

-SB

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.