473,473 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to update database through populated drop down menu in php

4 New Member
I want to know how to update a database by editing of retrieval through populated drop down menu.after searching a lot it could not work.so please help me.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. while($row1 = @mysql_fetch_array($aCustomer,MYSQL_ASSOC))
  3. {
  4. echo "&nbsp;&nbsp;&nbsp;head &nbsp;<input type='text' name='head' value='".$row1['head']."'><br/><br/>";
  5. echo "&nbsp;&nbsp;&nbsp;description &nbsp;<input type='text' name='description' value='".$row1['description']."'><br/><br/>";
  6. echo "&nbsp;&nbsp;&nbsp;file no &nbsp;<input type='varchar' name='fileno' value='".$row1['fileno']."'><br/><br/>";
  7. echo "&nbsp;&nbsp;&nbsp;Name of firm &nbsp;<input type='text' name='Nameoffirm' value='".$row1['Nameoffirm']."'><br/><br/>";
  8. echo "&nbsp;&nbsp;&nbsp;exp &nbsp;<input type='int' name='exp' value='".$row1['exp']."'><br/><br/>";
  9. echo "&nbsp;&nbsp;&nbsp;date of sanction &nbsp;<input type='date' name='dateofsanction' value='".$row1['dateofsanction']."'><br/><br/>";
  10. echo "&nbsp;&nbsp;&nbsp;date of po &nbsp;<input type='date' name='dateofpo' value='".$row1['dateofpo']."'><br/><br/>";
  11. echo "&nbsp;&nbsp;&nbsp;date of indent &nbsp;<input type='date' name='dateofindent' value='".$row1['dateofindent']."'><br/><br/>";
  12. echo "&nbsp;&nbsp;&nbsp;bill no &nbsp;<input type='int' name='billno' value='".$row1['billno']."'><br/><br/>";
  13. echo "&nbsp;&nbsp;&nbsp;date of bill no &nbsp;<input type='date' name='dateofbillno' value='".$row1['dateofbillno']."'><br/><br/>";
  14. echo "&nbsp;&nbsp;&nbsp;BLno &nbsp;<input type='int' name='BLno' value='".$row1['BLno']."'><br/><br/>";
  15. echo "&nbsp;&nbsp;&nbsp;bill pass &nbsp;<input type='varchar' name='billpass' value='".$row1['billpass']."'><br/><br/>";
  16. echo "&nbsp;&nbsp;&nbsp;bill amount &nbsp;<input type='int' name='billamt' value='".$row1['billamt']."'><br/><br/>";
  17. echo "&nbsp;&nbsp;&nbsp;date of bill &nbsp;<input type='date' name='dateofbill' value='".$row1['dateofbill']."'><br/><br/>";
  18. echo "&nbsp;&nbsp;&nbsp;available bal &nbsp;<input type='int' name='availbal' value='".$row1['availbal']."'><br/><br/>";
  19. echo "&nbsp;&nbsp;&nbsp;progressive bal &nbsp;<input type='int' name='progbal' value='".$row1['progbal']."'><br/><br/>";
  20. echo "&nbsp;&nbsp;&nbsp;remark &nbsp;<input type='varchar' name='remark' value='".$row1['remark']."'><br/><br/>";
  21. $head   = $row1['head'];
  22. $description = $row1['description'];
  23. $fileno   = $row1['fileno'];
  24. $Nameoffirm   = $row1['Nameoffirm'];
  25. $exp   = $row1['exp'];
  26. $dateofsanction   = $row1['dateofsanction'];
  27. $dateofpo  = $row1['dateofpo'];
  28. $indentno  = $row1['indentno'];
  29. $dateofindent   = $row1['dateofindent'];
  30. $billno   = $row1['billno'];
  31. $dateofbillno   = $row1['dateofbillno'];
  32. $BLno   = $row1['BLno'];
  33. $billpass   = $row1['billpass'];
  34. $billamt  = $row1['billamt'];
  35. $dateofbill   = $row1['dateofbill'];
  36. $availbal  = $row1['availbal'];
  37. $progbal   = $row1['progbal'];
  38. $remark   = $row1['remark'];
  39.  
  40. ?>
  41. <?php } ?>
  42.  
  43.  
  44. </table>
  45. </td>
  46. </tr>
  47. <?php } ?>
  48.  
  49. <form method="post">
  50.  
  51. <?php
  52. if(isset($_POST['update']))
  53. {
  54. $dbhost = 'localhost';
  55. $dbuser = 'root';
  56. $dbpass = '';
  57. $dbname = "purchase";
  58. $conn = mysql_connect($dbhost, $dbuser, $dbpass);
  59. mysql_select_db($dbname) or die(mysql_error());
  60. if(! $conn )
  61. {
  62.   die('Could not connect: ' . mysql_error());
  63. }
  64. $qry_result= mysql_query("SELECT RCtotal FROM nfcurrent") or die(mysql_error());
  65. $row=mysql_fetch_array($qry_result);
  66. $num=$row[RCtotal];
  67.  
  68. $description2 = $_POST['description'];
  69.  
  70. $fileno2=$_POST['fileno'];
  71.  
  72. $indentno2 = $_POST['indentno'];
  73.  
  74. $dateofindent2=$_POST['dateofindent'];
  75.  
  76. $billno2 = $_POST['billno'];
  77.  
  78. $dateofbillno=$_POST['dateofbillno'];;
  79.  
  80. $BLno2 = $_POST['BLno'];
  81. $billpass2 = $_POST['billpass'];
  82. $billamt2 = $_POST['billamt'];
  83. $dateofbill2=$_POST['dateofbill'];
  84.  
  85. $remark2 = $_POST['remark'];
  86. $availbal=$num;
  87. $progbal=$num-$billamt;
  88.  
  89. $sql = "UPDATE nfone
  90.        SET indentno ='$indentno2',
  91.            dateofindent = '$dateofindent2',
  92.            billno = '$billno2',
  93.            dateofbillno = '$dateofbillno2',
  94.            BLno = '$BLno2',
  95.            billpass = '$billpass2',
  96.            billamt = '$billamt2',
  97.            dateofbill = '$dateofbill2',
  98.            availbal = '$num',
  99.            progbal = '$progbal'
  100.  
  101.      WHERE fileno = '$fileno'";
  102.  
  103.  
  104. mysql_select_db('purchase');
  105. $retval = mysql_query( $sql, $conn );
  106. $RC=$progbal;
  107. $sqla = "UPDATE nfcurrent
  108.        SET RCtotal = '$progbal'";
  109.        $retvala = mysql_query( $sqla);
  110. if(! $retval )
  111. {
  112.   die('Could not update data: ' . mysql_error());
  113. }
  114.  
  115. echo "Updated data successfully\n";
  116.  
  117. mysql_close($conn);
  118. }
  119. else
  120.  
  121. ?>
  122. <input name="update" type="submit" id="update" value="Update">
  123. </form>
  124. </table>
  125. </form>
  126. </body>
  127. </html>
  128.  
May 17 '13 #1
0 1019

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: julian | last post by:
hi I was wondering if anyone can help me out on this.... I have dynamcally populated a drop down menu with data from an access database using ASP. The values seem fine, however when i pass...
5
by: Jim Bo | last post by:
Hi, I have a drop down menu that is being populated by a query to the access database ---- Code --- Skill needed <SELECT size="1" NAME="SkillType" VALUE="SkillType"> <OPTION>...
6
by: Greg Scharlemann | last post by:
I am attempting to populate a drop down menu based on the selection of a different drop down menu. However, it is not working correctly, I cannot figure out for the life of me what exactly happens...
3
by: phil | last post by:
We are developing specs. for a website for a nonprofit org, with database for membership related functions. But..question is regarding drop down menu links. We will have 20 category-pages, and...
8
by: barbarowa | last post by:
I've coded a script to populate a drop down menu from a database but I can't seem to get the PHP script to pass the selected item. The database only has two fields, ID and ITEM. I want the user...
2
by: millertime90 | last post by:
Hi basically my problem is I have 2 drop down menus populated by my database the first populated by a field in the database and the 2nd populated with a relation to the value selected in the first...
4
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me...
1
by: azeemqaiser | last post by:
Hi All, I have a form with two drop down controls. I want to change the values of Drop Down Menu 2 if i select some value in Drop Down Menu 1. Like If i select country then all the states of...
2
by: giandeo | last post by:
Hello all, It's almost a couple of weeks since i am struggling to get this code work. Unfortunately, i am stuck. There seems to be no hope... Please Help....... I am working with an asp page...
4
by: coder86 | last post by:
Hi, I am new to this site . I am looking for some help in updating my database from the value selected by user. Heres my page I have a table with rows of ID and its status. Status is a drop...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.