Jump to content

how to insert into a new table everytime the query is implemented


xclusivzik

Recommended Posts

i want a situation where, when i upload something into my database, it creates a new table, everytime, i saw this

$forum = "CREATE TABLE IF NOT EXISTS for_".$id." (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `stud` int(11) DEFAULT NULL,
  `course` int(11) DEFAULT NULL,
  `message` varchar(1000) DEFAULT NULL,
  PRIMARY KEY (`id`)
"; but don't know how to implement it into this query
$sql = "INSERT into data(name,Groups,phone_number) values('$data[0]','$data[1]','$data[2]')";
 
            

 

Something about your solution is flawed.  Why would you design a database structure that makes you create a whole new table for a set of data?  You defeat the whole purpose of having a well-organized database that facilitates the storage and ready retrieval of your data. Assuming that the sets of data each time refer to the same entities then putting those sets of data into separate tables is ridiculous.  How would you ever write a query to find a specifici set of data(aka, row)?

 

I urge you to re-think your db design here.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.