Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

show edit update

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
koop1koop
Asked:
koop1koop
  • 3
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
0
 
Ray PaseurCommented:
Can you please post the CREATE TABLE statement for the data base table you want to use? Thanks, ~Ray
0
 
koop1koopAuthor Commented:
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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
Ray PaseurCommented:
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
 
koop1koopAuthor Commented:
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
 
Ray PaseurCommented:
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now