php form handler
hey everyone i have a question about a form i have on my website.
its handled by a simple INSERT INTO php script. the problem i have is that there is a "category" field on the form that has 4 options.
the mysql database ive set up has 4 corresponding tables. can i use a set of conditionals to automatically send data to the correct table depending on what category they select?..or will i have to use a new form for each one?
any feed back would be great.
also, im new and id like to thank you guys in advance for any advice you have
i think i might have it. will this work?
<form action="handle_form.php" method="post">
<select multiple name="catgory[ ]">
and then use:
INSERT INTO "database" WHERE category =
to determine what category is displayed?
Just make the table definition in the SQL INSERT query a variable:
Then execute $query using the appropriate PHP command for your database.
$query="insert into $selected_category (field, ..., field) values(value, ..., value);"
As an aside, in the long run you might find it easier to consolidate all the tables into one, making "category" a field in the consolidated table.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)