How to upload to an expecific table in mysql due to answer

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ronald1989
Forum Newbie
Posts: 1
Joined: Fri Feb 24, 2012 1:28 am

How to upload to an expecific table in mysql due to answer

Post by ronald1989 »

I'm currently working with a form that i want it to update a table due to the answer provided by the user.

ex; if the user fill the form and says he is male, I want it to go to a table for males only and if the user answers female, then i would like it to go to a female only table on mysql database. can someone help me?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How to upload to an expecific table in mysql due to answ

Post by Celauran »

Code: Select all

$gender = ((int) $_POST['gender'] == 1) ? 'male_table' : 'female_table';
$query = "UPDATE {$gender} SET blah blah whatever";
Post Reply