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

I want to attach a condition to an updated record.

Thread began 4/16/2020 5:42 pm by Jonas | Last modified 4/21/2020 7:33 pm by Ray Borduin | 58 views | 7 replies |

Jonas

I want to attach a condition to an updated record.

I have the following code:
<?php
if (isset($_POST["ProvningOmbokning2Knapp"]) || isset($_POST["ProvningOmbokning2Knapp_x"])) {
$UpdateQuery = new WA_MySQLi_Query($AboutBeer);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "Bokning";
$UpdateQuery->bindColumn("BokningProvningOmbokningAdmin", "i", "".((isset($_POST["Nyprovning"]))?$_POST["Nyprovning"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("BokningOmbokningsavgiftBetalning", "i", "".((isset($_POST["Ombokningsavgift"]))?$_POST["Ombokningsavgift"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("BokningOmbokningsdatumAdmin", "s", "", "WA_CURRENT_TIMESTAMP");
$UpdateQuery->addFilter("BokningRefnr", "=", "i", "".((isset($_POST["BokningRefnr"]))?$_POST["BokningRefnr"]:"") ."");
$UpdateQuery->execute();
$UpdateGoTo = "../provningar/ombokning-tack.php?BokningRefnr=".((isset($_POST["BokningRefnr"]))?$_POST["BokningRefnr"]:"") ."".(isset($_GET["pageNum_BokningRefnr"])?"&pageNum_BokningRefnr=".intval($_GET["pageNum_BokningRefnr"]):"") ."";
if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
$UpdateQuery->redirect($UpdateGoTo);
}
?>

Now I want to add the following line with condition "$tidsskillnad > 72":
$UpdateQuery->bindColumn("BokningOmbokningBekraftadAdmin", "i", "1", "WA_DEFAULT");

I have tried to create a new update record that only has this update query and used show region utility around this new update record, but nothing happens.

Sign in to reply to this post

Ray BorduinWebAssist

$UpdateQuery->bindColumn("BokningOmbokningBekraftadAdmin", "i", "" .($tidsskillnad > 72?"1":"") ."", "WA_IGNORE");

Sign in to reply to this post
Did this help? Tips are appreciated...

Jonas

Great, thanks Ray!
How if I want to send an email with two different message based on condition (if $tidsskillnad > 72, or < 72)? Can I do this in the mail itself, using "show region utility", or do I need to change the code, the server behavior "Send Email" generate someway?

Sign in to reply to this post

Ray BorduinWebAssist

I'd just copy the entire code chunk and add that check to the trigger. Then you could easily changes in both scenarios including the body updates.

Sign in to reply to this post
Did this help? Tips are appreciated...

Jonas

Ok, that works well.
Heres one more similar question. I have two conditions for update record ("$tidsskillnad > 72") and ("$tidsskillnad < 72"). And I make two similar update records (with some differences). The trigger should be the same form button. How do I write this. I can't make it work. Heres the code chunk for first one:
if (("$tidsskillnad" > 72) || (isset($_POST["AvbokaProvning3Obekraftad"]) || isset($_POST["AvbokaProvning3Obekraftad_x"])))) {

"AvbokaProvning3Obekraftad" = button name

Sign in to reply to this post

Ray BorduinWebAssist

if (($tidsskillnad > 72) && ((isset($_POST["AvbokaProvning3Obekraftad"]) || isset($_POST["AvbokaProvning3Obekraftad_x"]))))) {

Sign in to reply to this post
Did this help? Tips are appreciated...

Jonas

I have tried your suggestion, but nothing happens when I press the button.
I also getting error message when I open Update record server behavior.

Sign in to reply to this post

Ray BorduinWebAssist

You have:

if ("$tidsskillnad"

but I think it should be:

if ($tidsskillnad

The error message is referring to the value you ahve for the redirect update go to on line 113.

The end of it should have two spaces before the double quote to fix that.

Sign in to reply to this post
Did this help? Tips are appreciated...

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