Sooo close!!! Please help
After 8 hours of trial and error, I saw this post and got soooo excited because it seemed to be exactly what I need but I cannot seem to get it to work. The difference in mine might be that I am loading the checkboxes dynamically form another table. I have gotten that part to work fine. I am wondering if you could shed some light on why this wont work for me based on my code?
Here is the dynamically loaded code which places the checkboxes on the page:
<?php require_once("Connections/Polk.php");
$sql = "SELECT * FROM agents";
$pResult=mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($pResult) == 0)
{
print "There are No Records";
}
else
{
while($tmp = mysql_fetch_assoc($pResult))
{
echo "<input type=\"checkbox\" name=\"agent_id[]\" value=\"".$tmp["ID"]."\" />"; echo $tmp['name'];
echo "<br />";
}
}
?>
Here is the insert code that was generated by Data Assist:
// WA Application Builder Insert
if (isset($_POST["Insert_x"])) // Trigger
{
$WA_connection = $Polk;
$WA_table = "test_table";
$WA_sessionName = "WADA_Insert_test_table";
$WA_redirectURL = "test_table_Detail.php";
$WA_keepQueryString = false;
$WA_indexField = "ID";
$WA_fieldNamesStr = "agent_id";
$WA_fieldValuesStr = "".((isset($_POST["agent_id"]))?$_POST["agent_id"]:"") ."";
$WA_columnTypesStr = "none,none,NULL";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_Polk;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>
It seems like I would need to edit this line as you suggested with the implode string but when I do that it just sends a 0 to the database.
$WA_fieldValuesStr = "".((isset($_POST["agent_id"]))?$_POST["agent_id"]:"") ."";