Jump to content

CheckBox to Select User from DB


matvespa

Recommended Posts

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";
}

?>

Link to comment
https://forums.phpfreaks.com/topic/191146-checkbox-to-select-user-from-db/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.