Jump to content

Converting table row filled with PHP value into editable form input


thenorman138

Recommended Posts

I have a page that displays about 12 tables that are filled from database values. These values correspond with a single record but some of these fields are based off of queries I'm making so that if something's wrong in the query, it will display red text. 
 
I'm only doing this for a few different fields but I want an option to edit and fix those fields and then save them to the database with an UPDATE.
 
Basically, I don't want to wrap the whole page in a form since only a few fields in a few of the tables will need to be editable. Is there a way to do this so that I can edit only the few fields that need to be fixed?
 
Here's a table as example:
 
    <div class="testResults" style=" width: 30%; clear:both; float: left;">
    <!--Test Results Table-->
    <table style="width: 100%;">
    <tr>
    <th colspan="2">Test Results</th>
    </tr>
    <tr>
    <td style="text-align: left;">Tested Within AWWA Standards</td>
    <td><? echo $row['standards'];?> </td>
    </tr>
    <tr>
    <td style="text-align: left;">Meter Failed on Low Side</td>
    <td><? echo $row['lowFail'];?> </td>
    </tr>
    <tr>
    <td style="text-align: left;">Meter Failed on High Side</td>
    <td><? echo $row['highFail'];?> </td>
    </tr>
    <tr>
    <td style="text-align: left;">Meter Failed Low and High Side</td>
    <td><? echo $row['bothFail'];?> </td>
    </tr>
    <tr>
    <td style="text-align: left;">Unable To Test</td>
    <td><? echo $row['unableTest'];?> </td>
    </tr>
    </table>
 
So, for example, say I want to edit the data for just standards row and lowFail row.
 
I tried this but it didn't work:
 
    <td><input type="text" name="test8TRGPM" value="<? echo $row['test8TestRateGPM'];?>"> </td>
 
I know once this is done I'll need to have a submit button that attaches to a query to update with the input name, but right NOw i'm trying to find the best way to edit.
 
Is it easiest to just wrap the whole page in a form and just create the few inputs where I need?

 

 
Link to comment
Share on other sites

Are these fields all inter-related throughout the entire page?  Or - are there groups of fields from one table at a time that will be edited?

 

Sure you can use one form but multiple may be better - depending on how you answer my first question.  Don't forget - you will need to have a key field hidden on the page for each table that needs to be edited/updated.  Also - will there be multiple records from any one table that may have multiple rows that need to be updated?  Again - more hidden keys.

 

Do you really need to be putting info from 12 tables all on one page?  Think about that.

Link to comment
Share on other sites

The reason there are multiple tables, is this is a digitized version of a current paper print out report with multiple tables for each section, but it all needs to be printed together. I have data from different DB tables filling these html tables, and most of it is read only. I can tell you this: one table has 4 fields that may need to be edited and there are 2 other tables with 1 field each that may be edited. So, 6 fields in total across 3 tables.

Link to comment
Share on other sites

When you say table, do you mean a graphical table from the report, or an html table that you are designing for display or a DB table that contains data?  Very confusing to read.

 

Again - you have to decide what's best for you with all these "tables" to be thinking about.  IF as I asked earlier the data from one graphical portion of your web page all belongs to one DB table, then I see that as a place for a single form to submit the needed data for a single db table update. 

 

This is all up to the designer - you.  But I would try to simplify as much as possible because we all know that you will re-visit this "thing" down the road and your memory won't be as clear next time.

Link to comment
Share on other sites

Sorry if that was confusing. Everything here starts in a staging table and then splits into smaller tables. All of my 12 html tables on the page are filled with data from 12 DB tables. So, each HTML table represents a DB table. They all fill properly, however, 3 tables contain info that may need to be edited if it's incorect on the report and then updated in the respective DB table. 

Link to comment
Share on other sites

What's a staging table - graphic, html or db?  See how confusing it can be right from the get-go?

 

ok - so each HTML table is data from one single db table.  Do the html tables contain multiple rows of data from the db behind them?  Then you may want to make each row(?) a form itself so that the user can make a change to something in that row and hit an 'Update' button to submit it.  Of course that means your whole page will need to be refreshed and that may be a logistical problem if the queries are complex that build the entire page.  Don't know if you are up on using AJAX, but that could be the better way to handle each 'row' update.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.