i want to check if a column contains any fieldvalues in a table.
cause i want to get the fieldvalues in a column and do something with them, but first i have to check whether they exist or not.
i have tried:
$query = "SELECT anonymous_username FROM users";
$result = mysqli_query($conn, $query) or die ("Couldn't execute query: " . mysqli_error($conn));
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result))
{
echo "exists";
}
}
but even when all the fields for that column were empty it echoed back 'exists'. so how can i do it?
EDIT: google is your friend:
$query = "SELECT anonymous_username FROM users WHERE anonymous_username <> '' AND anonymous_username IS NOT NULL";