WHERE statement in DB Record Loader

jan35utr 06 Mar, 2012
Hi,

I need some info on how to build the where statement in the DB Record Loader with data from a form field.

my form is connecting to a postcode database from the world, I need a where statement where two DB fields are set to the conditions from the form

e.g.
db.zip={zipcode_entered_from_form} AND db.cntry={CountryCode_entered_from_form}

please help me how to use these form fields in the where_statement box, tried several ways but till now no luck :-(

thx in advance,

Jan
GreyHead 06 Mar, 2012
Hi Jan,

That looks OK except that MySQL requires single quotes around test strings (and although not always necessary I prefer to add the backticks around column names:
db.`zip` = '{zipcode_entered_from_form}' AND db.`cntry` = '{CountryCode_entered_from_form}'


I'm not sure about the db. parts either - have you named the table AS db? If not leave them out
`zip` = '{zipcode_entered_from_form}' AND `cntry` = '{CountryCode_entered_from_form}'


Bob
jan35utr 06 Mar, 2012
Hi Bob,

I tried this and apparentely I still do something wrong

This line show all city records where postcode is hardcoded 1081 and countrycode hardecoded BE
`PostFrom`='1081' AND `CntryCD`='BE'

When changing the hardcoded values to the formfields, nothing is returned
`PostFrom`='{PostCode_aflever}' AND `CntryCD`='{land_aflever}'

the form is filled with below example url from the previous fill form
component/chronoforms/?PostCode_aflever=1081&land_aflever=BE&chronoform=Postcode_Sameday
GreyHead 06 Mar, 2012
Hi jan35utr ,

I just went and looked in the code and I don't think that the WHERE box supports curly brackets. Please try
`PostFrom`='<?php echo $form->data['PostCode_aflever']; ?>' 
  AND `CntryCD`='<?php echo $form->data['land_aflever']; ?>'


Bob
jan35utr 06 Mar, 2012
yeahhh!!! this works!

thanks ever so much

greetz,

Jan
This topic is locked and no more replies can be posted.