matvespa Posted February 6, 2010 Share Posted February 6, 2010 Hi, i have a 6 checkboxes which is supposed to call out a value from database. What i have in my database table is PreferRed, PreferWhite, PreferSparkling, PreferFortified and Email. The value for the PreferA-PreferD is either YES or NO. So I have a checkbox with 6 values (All, Red, White, Fortified, Sparkling, NoPreference). I need to know if Red-Sparkling is selected, and if yes, i need to call out the email of the user. And if All is selected, i need to filter it down from the database and same for NoPreference. I have a code but cant seem to be working. Does anyone know what wrong with the code? The code is just part of it. Tell me if im on the right track. Thanks! <?php $User=$_POST['User']; foreach ($User as $UserEmail) { echo "$UserEmail is checked<br>"; } if($UserEmail = All){ echo "SQL FOR ALL"; } elseif($UserEmail = Red){ { echo "SQL FOR Red" } elseif($UserEmail = White){ echo "SQL FOR White"; } elseif($UserEmail = Fortified){ echo "SQL FOR Fortified"; } elseif($UserEmail = Sparkling){ echo "SQL FOR Sparkling"; } else { echo "SQL FOR NO PREFERENCE"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/191146-checkbox-to-select-user-from-db/ Share on other sites More sharing options...
wildteen88 Posted February 6, 2010 Share Posted February 6, 2010 When comparing values use the comparison operator == (two equal signs) Quote Link to comment https://forums.phpfreaks.com/topic/191146-checkbox-to-select-user-from-db/#findComment-1007876 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.