I just try to get my own user management tool, so first of all I just want to display all users by using a table. Then I want to allow to change the roles of the users by using <select>
tags. My problem is that I want to get the current role of every user pre-selected and I want to have the possibility to change by getting an array of the possible roles by searching database. But how is this possible? Here you can see my code:
<?php
header('Content-Type: text/html; charset=UTF-8');
include("db.php"); //just the database connection
session_start();
?>
<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
</head>
<body>
</html>
<?php
$abfrage= mysql_query("SELECT * FROM user ORDER BY Name desc");
//$ergebnis = mysql_query($abfrage) or die( mysql_error() );
echo "<table>";
echo"<caption>Mitglieder<br></caption>";
echo"<table border=\"1\" style=\"width:300px\">";
echo "<th>Name</th>
<th>Prename</th>
<th>Role</th>";
while($row = mysql_fetch_object($abfrage)) {
echo "<tr>";
echo "<td align=center>",$row->Name,"</td>";
echo "<td align=center>",$row->Prename,"</td>";
echo "<td align=center><select><option value=",$row->Role,">",$row->Role,"</option></select></td>";
//Here is the Problem
echo "</tr>";
}
echo "</table>";
?>
It displays the table with the users and their role from database correctly. Bur I need to get the other roles selectable. I hope someone can help me.