473,586 Members | 2,555 Online
Bytes | Software Development & Data Engineering Community
+ 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 1030

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

Similar topics

3
11230
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 them to the next page (using form get method) the whitespaces in the values are ignored. For example with <option value=jim jones> then only "jim"...
5
5888
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> <%=SkillType%>
6
15405
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 because I am not getting any errors on the page. <html> <script language="javascript"> var phaseArray = new phaseArray(4); var phaseTypeId =...
3
1545
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 each page will have 30-50 links- unique to that page, so 1000+ total for site- on a drop down menu. Need we assume that such links (both plain...
8
7444
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 to be able to see all the choices and pick one. This choice would then be used to update another database. The drop down menu populates...
2
2849
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 and basically i'm just havin a problem refreshing the menus after i submit a value or refresh the page. My code is below: //javascript <script...
4
9282
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 if it works, and if it does not, tell me why it does not work. Thanks.
1
3038
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 this country should get populated in the second menu. Will appreciate your help.
2
3084
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 that dynamically pulls info from my database to populate a drop down menu. Upon an onChange event, I wish to display the fields related to that...
4
10699
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 down menu with 4 possible options. The default displayed is the value from database. When the user picks a value form drop down menu say "completed" I...
0
7839
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7959
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6614
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
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 we have to send another system
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.