Jump to content

Data Entry Grid


tbajaj

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 1 month later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.