Jul 27, 2004 #1 Thomas001 Programmer Jun 24, 2004 29 US How would I go about adding multiple fields to a MySQL database that a user can specify within the same page?
How would I go about adding multiple fields to a MySQL database that a user can specify within the same page?
Jul 27, 2004 Thread starter #2 Thomas001 Programmer Jun 24, 2004 29 US I know how to implement the for() loop.. But I don't know a good way to add multiple fields into my database. Upvote 0 Downvote
I know how to implement the for() loop.. But I don't know a good way to add multiple fields into my database.
Jul 27, 2004 1 #3 cLFlaVA Programmer Jun 14, 2004 6,450 US You could use the ALTER TABLE MySQL command. I'm pretty sure you could utilize "ALTER TABLE table_name ADD field_1 INT, ADD field_2 varchar(255), ..." So, with the for loop, you could build your syntax. $sql = "ALTER TABLE table_name "; for ($i = 0; $i < $num_fields; $i++) { $sql .= " ADD $field_name field_desc, "; } *cLFlaVA ---------------------------- A polar bear walks into a bar and says, "Can I have a ... beer?" The bartender asks, "What's with the big pause? Upvote 0 Downvote
You could use the ALTER TABLE MySQL command. I'm pretty sure you could utilize "ALTER TABLE table_name ADD field_1 INT, ADD field_2 varchar(255), ..." So, with the for loop, you could build your syntax. $sql = "ALTER TABLE table_name "; for ($i = 0; $i < $num_fields; $i++) { $sql .= " ADD $field_name field_desc, "; } *cLFlaVA ---------------------------- A polar bear walks into a bar and says, "Can I have a ... beer?" The bartender asks, "What's with the big pause?