close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Insert Record loop error

Thread began 2/16/2011 2:14 pm by fdotmedia | Last modified 2/16/2011 5:01 pm by fdotmedia | 968 views | 3 replies

fdotmedia

Insert Record loop error

My current task is to pull data from a "Results" table that stores one row of data from a form submission and populate a table of "Responses," for example ResultsID 15 would have an entry for Result1, Result2, Result3 and so on (up to 30). I'm taking that data and for every Result# I'm putting it into it's own Response row. So the Result1, Result2, Result3 from ResultsID 15 would now be ResponseIDs 24,25, and 26. (Numbers here are arbitrary).

In the code, I'm trying to do a loop - updating $i whenever it runs through the code. So in theory, I should only come up with 30 new Response rows - but what's happening is I'm returning an infinite number of Response rows that are filled with Result1.

Any idea what's going wrong?


<?php $i = 1; ?>
<?php $result = 'Result';?>

<?php

// This code inputs the data from the Results table into the Response table, for as many "ResultX" are in the Results table.
if ("" == "") // Trigger
{
$WA_connection = $surveys;
$WA_table = "Response";
$WA_sessionName = "Response_ReID";
$WA_redirectURL = "";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_indexField = "ReID";
$WA_fieldNamesStr = "ReOrder|UtID|TTID|PID|Response";
$WA_fieldValuesStr = "$i" . "|" . "".$row_resultrow['UtID'] ."" . "|" . "".$row_resultrow['TTID'] ."" . "|" . "".$row_resultrow['PID'] ."" . "|" . "".$row_resultrow["$result$i"] ."";
$WA_columnTypesStr = "none,none,NULL|',none,''|none,none,NULL|none,none,NULL|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_surveys;
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"];
$i = $i + 1;
}
header("Location: ".$WA_redirectURL);
}
} while ($i <= 30) ?>

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...