私はクエリに3つのテーブルを持ち、同じ変数を使って3つのテーブルの1つに値があるかどうかをチェックします。現時点では、if else condition
を使用して確認することが考えられます。以下にその例を示します。PHP - シンプルできちんとした方法をチェックするために...
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 */
}
}
もっと短くてすてきな方法がありますか?実は、私はCFDB
でワードプレスのプラグインを使用しています
更新コード
。私の実際のコードは。
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 . '"');
}
}
恐らく['UNION'](https://www.tutorialspoint.com/sql/sql/univers-clause.htm)があなたのケースでは役立つかもしれません。 –
@AlexHowanskyアイデアとリンクをありがとう。それを見て回ります。 – Amran
@AlexHowansky私の質問を更新します – Amran