There is a table contains columns like
username,settings1,settings2,settings3
username is a unique and settings1,2,3 is contain 0 or 1 values.
$query = $this->db->query("SELECT * FROM tbl_users WHERE username = 'test'");
$queryrow = $query->row();
so i want to select the row that matching to username and loop through columns and check which column contain 0’s and 1’s
i can do this by writing a if statement for every column though, like
if($queryrow->settings1=="1"){
..
}
there is like 7 columns in table so instead of writing 7 if statements, any other way to do this? im using codeigniter 2.0.2
Regards
You can iterate objects
If all you need to do in this loop is checking those values, you should do a SELECT to have only those items in $row, and avoid having “username”
Otherwise, if you want to keep username, the IF statement could be rather