Forum Moderators: coopster
I am currently putting together the User database which will keep track of what newsletters a user is subscribed to. My plan is to just use a separate column for each newsletter and then have a 1 or 0 for if the user is subscribed to said column.
What I can't figure out is how to simply list which newsletters (or columns) have a 1 as the field in php.
Any help would be greatly appreciated.
[webmasterworld.com...]
mysql_query( "SELECT * FROM users WHERE * = '1'")
It should be select [field list, or *] from [table] where [fieldname] = 1;
If it's a numeric data type, quoting is not necessary. If you have the value in a variable,
select * from users where fieldname = $var;
and the variable is null or empty, this will give a mysql error - but in reality, this is a good thing. It reveals something in your programming is allowing a null/empty value to pass through when it shouldn't be.
I bring this up because,
select * from users where fieldname = '$var';
. . . will not error on a numeric field if $var is empty. It will just return no records, and you can spend hours trying to figure out why. :-)