Need help in achieving a data entry grid.
I have two tables am_user (idam_user, name) and am_activity (idam_act, act) with the data
Data for am_user is
1, John
2, Mary
3, Kate
Data for am_activity is
1, Cooking
2, Cleaning
3, Painting
I have a third table that stores the role played by each user for the activities. am_role (idam_role, role)
1, Manage
2, Observe
3, Documents
I want my User table to be my header, Activity table to my 1st column and Role table to populate the data grid
[/td] [td]JohnMaryKate
CookingManageDocumentObserve
CleaningDocumentnullManage
PaintingObserveDocumentManage
By putting two while loops I am able to generate the header and 1st column but I need help in populating the grid in between.
Also I want my data entry area (rows and column besides header and 1st column) to have lookup where they can select values from the am_role table.
So, John can "Manage" "Painting" tomorrow if he wants to
The two while loops are
$query = "select idam_user, Name ";
$query .= " from am_user ";
$result = mysql_query($query) or die(mysql_error());
// display data in table
echo "<center>";
echo "<table>";
echo "<tr>";
echo "<th></th>";
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $result )) {
// echo out the contents of each row into a table
echo '<th>' . $row['name'] . ' ';
echo "</th>";
}
echo "</tr>";
$query = "select idam_act, act ";
$query .= " from am_activity ";
$result = mysql_query($query) or die(mysql_error());
// display data in table
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $result )) {
// echo out the contents of each row into a table
echo '<tr>';
echo '<td>' . $row['act'] . '</td>';
echo '</tr>';
}
// close table>
echo "</table>";
echo "</center>";
Please advise if this thought is realistic and how can I achieve it.
Thanks in anticipation.