How to seprate data from database in php with if condition?

Viewed 37

In my database there is a row in which there are some data strings are stored with separation of comma(,). And i want to show data on website with if condition. If there are more than 2 data strings.

if($row['category'] > 2){
  echo 'All Category';
}else{
  echo '.$row['category'].';
}
1 Answers

just do:

if(count(explode(',', $row['category'])) { 
   echo 'All Category'; 
} else {
   echo count(explode(',', $row['category']);
}
Related