prepare("SELECT * FROM users WHERE username = :username"); $result = $statement->execute(array('username' => $username)); $user = $statement->fetch(); $_SESSION['userid'] = $user['id']; $_SESSION['email'] = $user['email']; $_SESSION['username'] = $user['username']; $_SESSION['givenName'] = $user['givenName']; $_SESSION['lastName'] = $user['lastName']; $_SESSION['activated'] = $user['activated']; $_SESSION['updated_at'] = $user['updated_at']; $_SESSION['isadmin'] = $user['isadmin']; if($_SESSION['isadmin'] == 0) { die ('No rights for you! '); } echo ''; //create connection $connection = mysqli_connect($mysqlhost, $dbuser, $dbpass, $dbname); //test if connection failed if(mysqli_connect_errno()){ die("connection failed: " . mysqli_connect_error() . " (" . mysqli_connect_errno() . ")"); } //get results from database $result = mysqli_query($connection,"SELECT * FROM users"); $all_property = array(); //declare an array for saving property //showing property echo ''; //initialize table tag while ($property = mysqli_fetch_field($result)) { echo ''; //get field name for header array_push($all_property, $property->name); //save those to array } echo ''; //end tr tag //showing all data while ($row = mysqli_fetch_array($result)) { echo ""; foreach ($all_property as $item) { echo ''; //get items using property value } echo ''; } echo "
' . $property->name . '
' . $row[$item] . '
"; echo '

'; echo ''; ?>