简体   繁体   中英

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

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'].';
}

just do:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM