0

How can I define

$allRoles = array('musician', 'leader', 'singer'); // !important

above line dynamically in this answer? I mean to say $allRoles entities should come from MySQL table instead of define every entity here.

Community
  • 1
  • 1
  • Possible duplicate of [MySQL pivot row into dynamic number of columns](http://stackoverflow.com/questions/12004603/mysql-pivot-row-into-dynamic-number-of-columns) – Shadow Mar 14 '16 at 09:49
  • One of the answers on that link seems to answer the question, and use a database query. – halfer Mar 14 '16 at 18:33

1 Answers1

1
$query =  "select role from user_role";

$result = mysqli_query($con,$query);

$allroles = array();
    while($row = mysqli_fetch_array($result))
    {
        $allroles[] = $row['role'];
    }

print_r($allroles);