PDA

View Full Version : Dynamically create tables?


joviyach
04-30-2006, 05:57 PM
Is it possible to write something in PHP to dynamically create tables for MySQL. For example, you want to be able to catalog an item, you want to create different catagories for the item to be cataloged, can you write a program that will allow a user of the site to create these on the fly in MySQL?

GJay
04-30-2006, 06:02 PM
yes.
With mysql_query you can do pretty much anything you can do from a mysql command prompt.

I wouldn't reccomend it though, there's almost certainly a better way.

vinyl-junkie
04-30-2006, 06:37 PM
there's almost certainly a better way.
Yes, like a better database design, to preclude the need for creating tables dynamically. Perhaps you could describe the problem you're trying to solve more fully, then we could recommend possible solutions.

joviyach
04-30-2006, 07:34 PM
I want people to be able to catalog anything they want, and be able to name the categories of the items that they choose to catalog.

In other words, I don't want to say that they could only catalog CDs and then arbitrarily name the the categories they can use in order to do this.

MetalStorm
04-30-2006, 08:37 PM
How about an Item table, and a Category table, then reference the Category from the Item table.