if ($_POST['Submit']) {
$tablesArray = array('table1', 'table2', 'table3', 'table4', 'table5');
$checkTheseFieldsArray = array('pname', 'version', 'link');
$checkTheseFieldsLen = count($checkTheseFieldsArray);
extract($checkTheseFieldsArray);
extract($tablesArray);
$tablesLen = count($tableArray);
//create a date and time.
$date = date("Y-m-d");
$time = $_SERVER["REQUEST_TIME"];
//Tried using it the old fasioned way.
for ($x=0; $x < $tablesLen; $x++) {
if(!$_POST[eval("\$tablesArray\[\$x\]")]) {
$tablesArray[$x] = "";
} else {
$tablesArray[$x] = $_POST[$tablesArray[$x]]; }
}
//Tried using foreach loop
foreach($checkTheseFieldsArray as $value2) {
if(!$_POST[$value2]) {
$value2 = "";
} else {
$value2 = $_POST[$value2]; } }
foreach($tablesArray as $value3) {
if(${$value3} != "") {
$sql=mysql_query("INSERT INTO $value3 (area1, area2 , area3 , area4)
"."VALUES ('NULL', '$pname', '$version', '$link')") or die(mysql_error());
} }
}
//Contine on to form if not submitted
ex 1 input field
Link:
<input name="link" type="text" size="28" maxlength="128" />
//And one example checkbox for the tables.
<input type="checkbox" name="table1" />Table 1
As of now with real table values this inserts into all 5 of the tables instead of just the one defined (or checked).
Any Tips?
