Reputation: 657
I have 3 tables to queries and check if there is a value on one of the three table using a same variable. At the moment, I can think of is to use if else condition
to check. Below are the example,
if (isset($post_val)) {
$var= /* mysql queries table 1 */
}
if (empty($var)) {
$var= /* mysql queries table 2 */
if (empty($var)) {
$var= /* mysql queries table 3 */
}
}
Is there are more shorter or neat way to do it.
Update Codes
Actually, I am using a plugin from wordpress that is CFDB
. My actual code will be.
if (isset($vehicle_no)) {
$location = do_shortcode('[cfdb-value form="season parking form_copy" filter="your-platno=' . $vehicle_no . '"');
}
if (empty($location)) {
$location = do_shortcode('[cfdb-value form="season parking form" filter="your-platno=' . $vehicle_no . '"');
if (empty($location)) {
$location = do_shortcode('[cfdb-value form="Season Register 2017" filter="your-platno=' . $vehicle_no . '"');
}
}
Upvotes: 0
Views: 47
Reputation: 66
You could just union the tables together and then search that one. i.e.
if (isset($post_val)) {
$var= /* mysql queries table 1 UNION table2 UNION table3 */ ;
}
Upvotes: 1