close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

repeat region insert

Thread began 10/17/2013 12:37 pm by mr hankey | Last modified 10/17/2013 1:18 pm by Jason Byrnes | 1861 views | 4 replies |

mr hankey

repeat region insert

hi there,

I am trying to get a basic checklist working on the system however when you click the submit button it passes the answers into the url but does not insert to database. form code:

<form action="" method="post" name="checklist">

<?php
// RepeatSelectionCounter_1 Begin Loop
$RepeatSelectionCounter_1_IterationsRemaining = $RepeatSelectionCounter_1_Iterations;
while($RepeatSelectionCounter_1_IterationsRemaining--){
if($RepeatSelectionCounterBasedLooping_1 || $row_rsChecklist){
?>
<table>
<?php do { ?>
<tr>
<td>Question: <?php echo $row_rsChecklist['QuestionName']; ?></td>
<td><?php
// RepeatSelectionCounter_2 Begin Loop
$RepeatSelectionCounter_2_IterationsRemaining = $RepeatSelectionCounter_2_Iterations;
while($RepeatSelectionCounter_2_IterationsRemaining--){
if($RepeatSelectionCounterBasedLooping_2 || $row_rsChecklist){
?>
<input name="Answer_<?php echo $RepeatSelectionCounter_1; ?>_<?php echo $RepeatSelectionCounter_2; ?>" type="checkbox" value="" />
<input name="QuestionID_<?php echo $RepeatSelectionCounter_1; ?>_<?php echo $RepeatSelectionCounter_2; ?>" type="hidden" value="<?php echo $row_rsChecklist['QuestionID']; ?>" />
<input name="clients_ClientID_<?php echo $RepeatSelectionCounter_1; ?>_<?php echo $RepeatSelectionCounter_2; ?>" type="hidden" value="" />
<?php
} // RepeatSelectionCounter_2 Begin Alternate Content
else{
?>
<td>No records match your request.</td>
<?php } // RepeatSelectionCounter_2 End Alternate Content
if(!$RepeatSelectionCounterBasedLooping_2 && $RepeatSelectionCounter_2_IterationsRemaining != 0){
if(!$row_rsChecklist && $RepeatSelectionCounter_2_Iterations == -1){$RepeatSelectionCounter_2_IterationsRemaining = 0;}
$row_rsChecklist = mysql_fetch_assoc($rsChecklist);
}
$RepeatSelectionCounter_2++;
} // RepeatSelectionCounter_2 End Loop
?>
</td>
</tr>
<?php } while ($row_rsChecklist = mysql_fetch_assoc($rsChecklist)); ?>
</table>
<?php
} // RepeatSelectionCounter_1 Begin Alternate Content
else{
?>
<td>No records match your request.</td>
<?php } // RepeatSelectionCounter_1 End Alternate Content
if(!$RepeatSelectionCounterBasedLooping_1 && $RepeatSelectionCounter_1_IterationsRemaining != 0){
if(!$row_rsChecklist && $RepeatSelectionCounter_1_Iterations == -1){$RepeatSelectionCounter_1_IterationsRemaining = 0;}
$row_rsChecklist = mysql_fetch_assoc($rsChecklist);
}
$RepeatSelectionCounter_1++;
} // RepeatSelectionCounter_1 End Loop
?>
<input name="Submit" type="submit" value="1" />
</form>

php:
<?php
// WA DataAssist Multiple Inserts
if ($_SERVER["REQUEST_METHOD"] == "POST") // Trigger
{
if (!session_id()) session_start();
$WA_loopedFields = array("");
$WA_connection = $cbank;
$WA_table = "checklistanswers";
$WA_redirectURL = "login.php";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_fieldNamesStr = "question_QuestionID|Answer|clients_ClientID";
$WA_columnTypesStr = "none,none,NULL|',none,''|none,none,NULL";
$WA_insertIfNotBlank = "";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_cbank;
$WA_multipleInsertCounter = 0;
mysql_select_db($WA_connectionDB, $WA_connection);
while (WA_AB_checkMultiInsertLoopedFieldsExist($WA_loopedFields, $WA_multipleInsertCounter)) {
if ($WA_insertIfNotBlank == "" || WA_AB_checkLoopedFieldsNotBlank(array($WA_insertIfNotBlank), $WA_multipleInsertCounter)) {
$WA_fieldValuesStr = "".((isset($_GET["QuestionID"]))?$_GET["QuestionID"]:"") ."" . "|" . "".((isset($_GET["Answer"]))?$_GET["Answer"]:"") ."" . "|" . "".$_GET['ClientID'] ."";
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$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());
}
$WA_multipleInsertCounter++;
}
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);
}
}
?>
<?php
// RepeatSelectionCounter_1 Initialization
$RepeatSelectionCounter_1 = 0;
$RepeatSelectionCounterBasedLooping_1 = false;
$RepeatSelectionCounter_1_Iterations = "1";
?>
<?php
// RepeatSelectionCounter_2 Initialization
$RepeatSelectionCounter_2 = 0;
$RepeatSelectionCounterBasedLooping_2 = false;
$RepeatSelectionCounter_2_Iterations = "1";
?>

I have not used webassist products for a while as I found I could not get things working and would like to use this to build a survey. if I could get this working it would help me consider upgrading to data bridge possibly but for some reason my data assist is not working with the insert?

thanks

Sign in to reply to this post

Jason ByrnesWebAssist

I'll need to troubleshoot directly, see the private message section.

Sign in to reply to this post

mr hankey

reply sent, thanks Jason

Sign in to reply to this post

mr hankey

ok I actually have this working now. I did not use the data assist repeat selector which seemed to cause the issue.

all sorted which is great. however. I need the ability to have different field types for the answers. example.

checkbox
input
select

this would be based on the question setup in MySQL. can I show one or the other depending on the question in the multiple insert?

many thanks

Sign in to reply to this post

Jason ByrnesWebAssist

yes, but you would need to hand code this.

you would need a question type column then use an if statement to set the element type based on the question type.

this will require custom coding to accomplish, if you need help with setting this up, i suggest signing up for a premiere support appointment.

Sign in to reply to this post

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...