close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

How to generate a "non existent value"?

Thread began 6/13/2013 7:50 am by info4753 | Last modified 6/14/2013 7:15 am by Jason Byrnes | 876 views | 9 replies |

info4753

How to generate a "non existent value"?

I'm working on a validation that compares a POST variable (param) from a form with database values in order to avoid double entries. (it's a room reservation application where the user can book a room for the morning (value 1 for DAUERID), afternoon(2) or the whole day (3) (you can't book a morning if the whole day is already taken). The validation works as long as there is a value for the DAUERID in the table reservation table but the select statement returns no value (from the recordset) if there is no DAUERID value for the parameter to compare. So the validation fails. Here is the select statement:

SELECT DAUERID, ( CASE
WHEN param = 1 AND DAUERID = 1 THEN 1
WHEN param = 1 AND DAUERID = 3 THEN 1
WHEN param = 1 AND DAUERID = 2 THEN 0
WHEN param = 2 AND DAUERID = 1 THEN 0
WHEN param = 2 AND DAUERID = 3 THEN 1
WHEN param = 2 AND DAUERID = 2 THEN 1
WHEN param = 3 AND DAUERID = 1 THEN 1
WHEN param = 3 AND DAUERID = 2 THEN 1
WHEN param = 3 AND DAUERID = 3 THEN 1
ELSE 0
END) AS result
FROM res_reservationen

It looks like ELSE 0 is not working, means result is empty. Any ideas how to fix this problem? Thanks in advance!

Sign in to reply to this post

Jason ByrnesWebAssist

the recordset looks correct, i don't think that is the problem.

Send a copy of the page please so i can see the code in context.

Sign in to reply to this post

info4753

Thanks Jason.

There are two cases that I need to cover in the validation:

1. result is not getting a value so I need to validate agains an empty recordset
2. result gets a value so I need the validate against -1,0 range

I guess I need a "OR" between the two validations. Is this possible? Here are the two validations:

<?php
if (isset($_POST["InfraparkReservation_submit"]) || isset($_POST["InfraparkReservation_submit_x"])) {
$WAFV_Redirect = "res_formular1.php?ERROR=6";
$_SESSION['WAVT_resformular2_310_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateNM($row_rsReservationenCheck['resultat'] . "",-1,0,"",",.",true,1);

if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"resformular2_310");
}
}
?>
<?php
if (isset($_POST["InfraparkReservation_submit"]) || isset($_POST["InfraparkReservation_submit_x"])) {
$WAFV_Redirect = "res_formular1.php?ERROR=6";
$_SESSION['WAVT_resformular2_956_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateNM($totalRows_rsReservationenCheck . "",-1,0,"",",.",true,2);

if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"resformular2_956");
}
}
?>

Sign in to reply to this post

Jason ByrnesWebAssist

i dont think i understand what you are trying to accomplish.

Sign in to reply to this post

info4753

I have a room reservation system where you can select the room and the time you use the room. The time is dived into morning, afternoon and the whole day. I did this by using DAUERID with 1 (morning), 2(afternoon) and 3(day) values.

Now the problem is that if the whole day is already taken and another customer want's to book the room only for the morning, I have the DAUERID = 1 from the form that has to be validated against a DAUERID of 1 in the reservation table but also for a DAUERID of 3 in the reservation table.

So what I did is this CASE szenario to generate a value (0 or 1) for "result" that helps me to validate available entries in the reservation table. But if there is no reservation for that day in the reservation atble, the recordset returns empty and therefore no 0/1 values.

What I need is a validation like "if return is 0 OR the recordset is empty, accept booking".

Sign in to reply to this post

Jason ByrnesWebAssist

see private message:

Sign in to reply to this post

info4753

see private message

Sign in to reply to this post

Jason ByrnesWebAssist

Originally Said By: info4753
  see private message  
Sign in to reply to this post

info4753

It looks like I've fixed the problem.

The Selcet/case Statement was correct, but I had a wrong declared POST parameter in the recordset filter. The empty recordset case has been cover by "if recordset is not empty" condition.

Thanks for your help, support from WA is really great and I'm looking forward to the next versions of your software.

Sign in to reply to this post

Jason ByrnesWebAssist

Ok, glad to hear it is working.

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