My question is not a duplicate and it has complex conditions. Please let me explain. In my second condition, first I need to check if number value is correct (in first condition I checked complete opposite). If so, then check if there's a value in email column. Then show error message if there's a value in email column. My problem is I need to write first query (already done by me) and second query under the same 'db_select'
Checking for email value only activates if webform value matches a value in 'number' column.
I have a table containing two columns namely, 'number' and 'email'.
I need to run a db_select
query to display same error message when a webform is submitted. My conditions are as follows:
- Show error message if number value provided by webform does not matches a value in 'number' column
- Show error message if number value provided by webform matches a value in 'number' column but corresponding 'email' column is not empty.
So far I'm able to show error message for the first condition.
db_set_active('mydatabase');
$query = db_select('mytable', 'c');
$query->fields('c', array('number','email_address'))
->condition('number', $phoneval, '=');
$result = $query->execute()->fetchAll();
if (empty($result))
{
form_set_error('phone_number','We have no record of that Assessment Number');
}
How can I show the same error message for condition 2? I don not want to query the database again and thinking of using for db_or
this.
Thanks