unemployment Posted April 25, 2011 Share Posted April 25, 2011 What is the best way to say... If more than two of these if's are satisfied, do this... if ((isset($_POST['credentials'])) && ($_POST['credentials'] != $r['credentials'])) { $details = ''; update_user_actions(2, $details); } if ((isset($_POST['specialties'])) && ($_POST['specialties'] != $r['specialties'])) { $details = ''; update_user_actions(3, $details); } if ((isset($_POST['personalweb'])) && ($_POST['personalweb'] != $r['personalweb'])) { $details = $_POST['personalweb']; update_user_actions(4, $details); } Quote Link to comment Share on other sites More sharing options...
Fadion Posted April 25, 2011 Share Posted April 25, 2011 The quick way would be adding a counter that gets incremented for every satisfied condition. Something like this: <?php $if_count = 0; if ((isset($_POST['credentials'])) && ($_POST['credentials'] != $r['credentials'])) { $details = ''; update_user_actions(2, $details); $if_count++; } if ((isset($_POST['specialties'])) && ($_POST['specialties'] != $r['specialties'])) { $details = ''; update_user_actions(3, $details); $if_count++; } if ((isset($_POST['personalweb'])) && ($_POST['personalweb'] != $r['personalweb'])) { $details = $_POST['personalweb']; update_user_actions(4, $details); $if_count++; } if ($if_count >= 2) { //do this } ?> If $if_count = 0, no condition is satisfied. If $if_count = 1, 1 condition is satisfied and so on up to 3 (all conditions satisfied). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.