close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Help with loop to reset a field after form submission

Thread began 2/09/2012 2:29 pm by iainmacdonald331081 | Last modified 2/10/2012 2:50 pm by Jason Byrnes | 1167 views | 13 replies |

iainmacdonald331081

Help with loop to reset a field after form submission

Hope someone might be able to help with this. Its something that I'm pretty certain was working, but now no longer seems to be.

Basically the set up is that a site owner can select a number of contact using checkboxes to send an email out to people. (So its using Universal Email as well.)

The way its set up is that there's a database field 'Email List' and the site owner selected the contacts, setting that field to Y, and then the email is sent to everyone with Email List=Y.

And then once the email has been sent, there's a button which should reset the value of 'Email List' back to N, so that each time the system is used, its with a fresh list of contacts.

The problem is that the reset doesn't seem to be working anymore.

I have attached the page that should be doing this - not sure what's happened, as I'm sure it did work in the past.

The code that should be doing it is:

<?php
// WA DataAssist Multiple Updates
if ($_SERVER["REQUEST_METHOD"] == "POST") // Trigger
{
if (!session_id()) session_start();
$WA_loopedIDField = array("WADA_RepeatID_CandidateID");
$WA_connection = $connSearchTechUK;
$WA_table = "Candidates";
$WA_redirectURL = "admin.php";
$WA_keepQueryString = false;
$WA_indexField = "CandidateID";
$WA_fieldNamesStr = "EmailList";
$WA_columnTypesStr = "none,'Y','N'";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_connSearchTechUK;
$WA_multipleUpdateCounter = 0;
mysql_select_db($WA_connectionDB, $WA_connection);
while (WA_AB_checkLoopedFieldsNotBlank($WA_loopedIDField, $WA_multipleUpdateCounter)) {
$WA_fieldValuesStr = "".$row_rsEmail['N'] ."";
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_where_fieldValuesStr = WA_AB_getLoopedFieldValue($WA_loopedIDField[0], $WA_multipleUpdateCounter);
$WA_where_columnTypesStr = "none,none,NULL";
$WA_where_comparisonStr = "=";
$WA_where_fieldNames = explode("|", $WA_indexField);
$WA_where_fieldValues = explode("|", $WA_where_fieldValuesStr);
$WA_where_columns = explode("|", $WA_where_columnTypesStr);
$WA_where_comparisons = explode("|", $WA_where_comparisonStr);
$updateParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WhereObj = WA_AB_generateWhereClause($WA_where_fieldNames, $WA_where_columns, $WA_where_fieldValues, $WA_where_comparisons );
$WA_Sql = "UPDATE `" . $WA_table . "` SET " . $updateParamsObj->WA_setValues . " WHERE " . $WhereObj->sqlWhereClause . "";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$WA_multipleUpdateCounter++;
}
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);
}
}
?>



Thanks.

Attached Files
emailCanSent.zip
Sign in to reply to this post

Jason ByrnesWebAssist

the value of the email list hidden element is set to Y:

php:
<input name="EmailList_<?php echo $RepeatSelectionCounter_1?>" type="hidden" id="EmailList_<?php echo $RepeatSelectionCounter_1?>" value="Y" <?php if (!(strcmp($row_rsEmail['EmailList'],"Y"))) {echo "checked=\"checked\"";} ?> />




change it to N

php:
<input name="EmailList_<?php echo $RepeatSelectionCounter_1?>" type="hidden" id="EmailList_<?php echo $RepeatSelectionCounter_1?>" value="N"  />
Sign in to reply to this post

iainmacdonald331081

Thanks Jason - that didn't seem to work.

I tried changing:

<input name="EmailList_<?php echo $RepeatSelectionCounter_1; ?>" type="hidden" id="EmailList_<?php echo $RepeatSelectionCounter_1; ?>" value="Y" <?php if (!(strcmp($row_rsEmail['EmailList'],"Y"))) {echo "checked=\"checked\"";} ?> />



to

<input name="EmailList_<?php echo $RepeatSelectionCounter_1; ?>" type="hidden" id="EmailList_<?php echo $RepeatSelectionCounter_1; ?>" value="N"  />



and also

<input name="EmailList_<?php echo $RepeatSelectionCounter_1; ?>" type="hidden" id="EmailList_<?php echo $RepeatSelectionCounter_1; ?>" value="N" <?php if (!(strcmp($row_rsEmail['EmailList'],"N"))) {echo "checked=\"checked\"";} ?> />



But no luck with either.

Sign in to reply to this post

iainmacdonald331081

Thought I might have misread that yesterday, so also tried:

<input name="EmailList_<?php echo $RepeatSelectionCounter_1; ?>" type="hidden" id="EmailList_<?php echo $RepeatSelectionCounter_1; ?>" value="N" <?php if (!(strcmp($row_rsEmail['EmailList'],"Y"))) {echo "checked=\"checked\"";} ?> />



But that didn't work either.

As I'm pretty sure it was working, I was trying to think of anything that might have changed - we moved the site over to new hosting at the end of last year, but that all seems to be OK - the database seems fine, along with adding / editing records etc on the site.

The only other thing I could think of was maybe to do with the PHP version running on the server - I know a couple of hosting companies that have recently upgraded - so for what its worth, the site is using PHP 5.3.10.

Sign in to reply to this post

Jason ByrnesWebAssist

just to make sure i understand correctly, when the reset button is pressed, you want to update every record in he table where the EmailList = Y to N?

for this you don't need to use a multiple record update, use the single record update instead.


set the trigger to happen on submit button pressed.

for the Key column, select the EmailList column, set the Value to Y

then on the second page of the update record behavior, set the value for the EmailList to N

Sign in to reply to this post

iainmacdonald331081

That's right Jason - the search selects the candidates to send the email to, by switching EmailList to Y. And the reset button should change them all back to N again.

Seems counter intuitive for it to be a single record update if there are multiple records to update / change back to N?

I tried it out, but still not working though - have attached that version of the file.

Attached Files
emailCanSent2.zip
Sign in to reply to this post

Jason ByrnesWebAssist

Can you send a screen shot showing the table structure for the Candidates table.

Sign in to reply to this post

iainmacdonald331081

Find attached...

Sign in to reply to this post

iainmacdonald331081

Not sure if that's shrunk it down, or if you can see the full size version. I've attached it zipped up here in case.

Attached Files
candidates.zip
Sign in to reply to this post

Jason ByrnesWebAssist

that screen shot is a little small so difficult o read, but it looks like the EmailList column does not use Y/N but rather Yes/No

can you send another screen shot showing one of the records that is set to Y and one that is set to N

Sign in to reply to this post
loading

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