tbajaj Posted February 29, 2012 Share Posted February 29, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/257963-data-entry-grid/ Share on other sites More sharing options...
Muddy_Funster Posted February 29, 2012 Share Posted February 29, 2012 as you are using three completly unrelated tables the best thing to do would be to build a variable that stores your option list (dropdown box) at the start, and then echo that variable for each of the fields. I'm having a hard time seing the point to this, but your likely going to need at least 1 counter within one of your loops in order to refference either the rows or columns that you have in the table so that you can apply that to the number of times accross or down you need to fill in the option list, depending on which loop you don't include the option list echo code in. I'm sure there has to be a better way of achieving what you are looking for as the end result. If your up for some rediesign post up your remit for this task and well have a look at alternatives. Quote Link to comment https://forums.phpfreaks.com/topic/257963-data-entry-grid/#findComment-1322218 Share on other sites More sharing options...
saleembdr Posted April 22, 2012 Share Posted April 22, 2012 Check this web data entry grid component: www.dataentrygrid.tk Quote Link to comment https://forums.phpfreaks.com/topic/257963-data-entry-grid/#findComment-1339475 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.