Solved

show edit update

Posted on 2011-09-06
6
182 Views
Last Modified: 2012-05-12
I am looking for a script baseis that will allow me to show results from multiple rows and colums into different input fields, the fields can be edited and the MYSQL update on the fly if possible.

Can anyone point me in the right direction or show me a sample script please?
0
Comment
Question by:koop1koop
  • 3
  • 2
6 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 36489962
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 36490017
Can you please post the CREATE TABLE statement for the data base table you want to use? Thanks, ~Ray
0
 

Author Comment

by:koop1koop
ID: 36490096
CREATE TABLE IF NOT EXISTS `Demo_budget` (
  `B_ID` int(11) NOT NULL auto_increment,
  `item` varchar(255) NOT NULL,
  `budget` decimal(10,2) NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `deposit` decimal(10,2) NOT NULL,
  `1st` decimal(10,2) NOT NULL,
  `2nd` decimal(10,2) NOT NULL,
  `final` decimal(10,2) NOT NULL,
  UNIQUE KEY `B_ID` (`B_ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=63 ;

--
-- Dumping data for table `Demo_budget`
--

INSERT INTO `Demo_budget` (`B_ID`, `item`, `budget`, `amount`, `deposit`, `1st`, `2nd`, `final`) VALUES
(1, 'item_1', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00'),
(2, 'item_2', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00'),
(3, 'item_3', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00'),
(4, 'item_4', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00'),
(5, 'item_5', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00'),
(6, 'item_6', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00'),
(7, 'item_7', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00'),
(8, 'item_8', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00'),
(9, 'item_9', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00'),
(10, 'item_10', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00'),
(11, 'item_11', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00'),
(12, 'item_12', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00'),
(13, 'item_13', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00'),
(14, 'item_14', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00'),
(15, 'item_15', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00'),
(16, 'item_16', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00'),
(17, 'item_17', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00'),


(10, 'item_8', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00'),

;
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 109

Expert Comment

by:Ray Paseur
ID: 36490521
OK, it looks like that will fit into a tabular display in a browser window.  Forgive the narrative answer here.  I will write an article to demonstrate the techniques, but I doubt if I will complete it in a way that will be timely for your needs.  You can either update one row or all rows.  If you prepopulate the form, either approach will work.

SELECT all the rows you want from the Demo_budget table.  You might also select the column names with something like SHOW COLUMNS.  You could use the column names for HTML column headers.

Using the auto_increment key column, you can create URLS that look like update.php?key=11  When that URL is submitted, it would SELECT all WHERE B_ID = (int)$_GET["key"] LIMIT 1 and it would use the resulting one row to prepopulate the value attributes of the input tags.  Each column of the data base row would have one input tag associated with it (except the key).  The client is then free to change the data.  When the client fires the submit button, the action script updates the data base using a WHERE clause pointing to the B_ID key and a LIMIT 1 clause.

0
 

Author Comment

by:koop1koop
ID: 36490700
i think what I am looking for is where each row is displayed in relevent text fields. The main part that I am having problems with is that I am unable to show the results of the MYSQL in each text field as in the following:-

<table width="1000" border="0" cellpadding="2" cellspacing="0">
  <tr>
    <td colspan="2">&nbsp;</td>
    <td width="100"><div align="center"><strong>Budget</strong></div></td>
    <td width="100"><div align="center" style="font-weight: bold">Actual <br>
      Amount</div></td>
    <td width="100"><div align="center"><strong>Deposit</strong></div></td>
    <td width="100"><div align="center"><strong>1st<br />
    Payment</strong></div></td>
    <td width="100"><div align="center"><strong>2nd <br />
    Payment</strong></div></td>
    <td width="100"><div align="center"><strong>Final <br>
      Payment</strong></div></td>
    <td width="100"><div align="center"><strong>Amount <br>
      Paid</strong></div></td>
    <td width="100"><div align="center"><strong>Balance <br>
      Due</strong></div></td>
  </tr>
  <tr>
    <td colspan="10" bgcolor="#999999">&nbsp;</td>
    </tr>
  <tr>
    <td width="5">&nbsp;</td>
    <td bordercolor="#999999"><div align="left">Item_1</div></td>
    <td bordercolor="#999999"><div align="center">
      <input name="item_1" type="text" id="item_1" size="15" />
    </div></td>
    <td bordercolor="#999999"><div align="center">
        <input name="item_2" type="text" id="item_2" size="15">
    </div></td>
    <td bordercolor="#999999"><div align="center">
        <input name="item_3" type="text" id="item_3" size="15">
    </div></td>
    <td bordercolor="#999999"><div align="center">
        <input name="item_4" type="text" id="item_4" size="15">
    </div></td>
    <td bordercolor="#999999"><div align="center">
        <input name="item_5" type="text" id="item_5" size="15">
    </div></td>
    <td bordercolor="#999999"><div align="center">
        <input name="item_6" type="text" id="item_6" size="15">
    </div></td>
    <td bordercolor="#999999"><div align="center"></div></td>
    <td bordercolor="#999999"><div align="center"></div></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div align="left">Item_2</div></td>
    <td bordercolor="#999999"><div align="center">
      <input name="item_7" type="text" id="item_7" size="15" />
    </div></td>
    <td bordercolor="#999999"><div align="center">
      <input name="item_8" type="text" id="item_8" size="15" />
    </div></td>
    <td bordercolor="#999999"><div align="center">
      <input name="item_9" type="text" id="item_9" size="15" />
    </div></td>
    <td bordercolor="#999999"><div align="center">
      <input name="item_10" type="text" id="item_10" size="15" />
    </div></td>
    <td bordercolor="#999999"><div align="center">
      <input name="item_11" type="text" id="item_11" size="15" />
    </div></td>
    <td bordercolor="#999999"><div align="center">
      <input name="item_12" type="text" id="item_12" size="15" />
    </div></td>
    <td bordercolor="#999999"><div align="center"></div></td>
    <td bordercolor="#999999"><div align="center"></div></td>
  </tr>
  
  <tr>
    <td>&nbsp;</td>
    <td> <div align="left">Item_3</div></td>
    <td bordercolor="#999999"><div align="center">
      <input name="item_13" type="text" id="item_13" size="15" />
    </div></td>
    <td bordercolor="#999999"><div align="center">
      <input name="item_14" type="text" id="item_14" size="15" />
    </div></td>
    <td bordercolor="#999999"><div align="center">
      <input name="item_15" type="text" id="item_15" size="15" />
    </div></td>
    <td bordercolor="#999999"><div align="center">
      <input name="item_16" type="text" id="item_16" size="15" />
    </div></td>
    <td bordercolor="#999999"><div align="center">
      <input name="item_17" type="text" id="item_17" size="15" />
    </div></td>
    <td bordercolor="#999999"><div align="center">
      <input name="item_18" type="text" id="item_18" size="15" />
    </div></td>
    <td bordercolor="#999999"><div align="center"></div></td>
    <td bordercolor="#999999"><div align="center"></div></td>
  </tr>
</table>

Open in new window

0
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 250 total points
ID: 36490747
Line 26 of the second script.  After you have made the query and retrieved the $row variable representing a single row from the data base, let's assume that "item_1" in the HTML form is the "budget" column in the data base table.  You might  have something like this to inject the PHP value into the HTML form:

<input name="item_1" type="text" id="item_1" size="15" value="<?php echo $row['budget']: ?>" />

It will be easier if you name the columns in the data base table and the name attributes in the form with exactly the same names (case-sensitive and following the PHP variable naming guidelines).
http://us.php.net/manual/en/language.variables.basics.php
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question