I am trying to use one submission page to submit form data to various tables. I want to be able to use a text field or a select/menu in a form to determine which table the data will be submitted to. I have tables named men, women, youth, special_events, etc. All the tables have the same structure newsID, title, description, and date.
I remembered the spaces after I posted, that didn't help any...
I keep getting this error
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(newsID, title, `description`, `date`) VALUES (NULL, 'Test #1', 'This is a test ' at line 1
I figured it out...duh, and i'll explain it for those who maybe new or don't get it
$_POST['table'] = $news_table;
$_POST['table'] is the value of whatever my text field with the name of "table".
$news_table is a variable just created, so it has no value.
PHP works left to right, up to down, like any normal code.
Well when you think about the statement above, instead of "is equal to", it actually means "is now equal to", and since $news_table is a blank, I have now set my value from "table" to nothing, hence the nulled (blank) output.
$news_table = $_POST['table']
Now the $news_table variable "is now equal to" $_POST['table'], making the $news_table variable have the value of "table"
PS> Have no idea why I just explained it, but sometimes we just get lost in code...