-2

I have a table with several columns and one of the column data type is SET. When retrieving, I want to retrieve the vales in SET as an array.

$getfirstlevel=mysqli_query($db,"SELECT * FROM aaa_menu WHERE type='page' and id = '$item' and level = 'first' and status = 'Active' ORDER BY menu_order ASC");
  while($flrow=mysqli_fetch_assoc($getfirstlevel)){
        $account_select_status_fl=$flrow['account_select_status'];
        $account_type_status_fl=$flrow['account_type']; <=== this column is datatype SET with multiple values. Hence I would like to have it returned as an array.
}
Dharman
  • 30,962
  • 25
  • 85
  • 135
  • **Warning:** You are wide open to [SQL Injections](https://php.net/manual/en/security.database.sql-injection.php) and should use parameterized **prepared statements** instead of manually building your queries. They are provided by [PDO](https://php.net/manual/pdo.prepared-statements.php) or by [MySQLi](https://php.net/manual/mysqli.quickstart.prepared-statements.php). Never trust any kind of input! Even when your queries are executed only by trusted users, [you are still in risk of corrupting your data](http://bobby-tables.com/). [Escaping is not enough!](https://stackoverflow.com/q/5741187) – Dharman Aug 13 '21 at 01:08

1 Answers1

-1

You are fetching the data in an array format using mysql_fetch_assoc which means the data should return in an associative array.

to fix your issue I believe typecasting would suffice.

change the $account_type_status_fl=$flrow['account_type']; to $account_type_status_fl = (array)$flrow['account_type']; 
Cdev
  • 1
  • 1
  • 1