By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,040 Members | 1,815 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,040 IT Pros & Developers. It's quick & easy.

How to extract data from sql DB into the form

P: 1
Hi All,

I am looking for the solution of following case.
I am trying to get the data from SQL DB in the form fields which i have created in the form. I am able to input through these fields but I also want to retrieve the data in the same form.
Please help me out as soon as possible. I attached the code for input form.

INPUT AND OUTPUT PAGE CODE (MAINPAGE.PHP)
Expand|Select|Wrap|Line Numbers
  1. <html> 
  2. <head>
  3. <!-- @@@@@@@@@@@@@@@@@@@@@@@@@ date Picker script @@@@@@@@@@@@@@@@@@@@@@@@@@@ -->
  4. <style>
  5.  
  6. label{
  7.  
  8. width: 6em;
  9.  
  10. float: left;
  11.  
  12. text-align: right;
  13.  
  14. margin-right: 8em;
  15.  
  16. display: block
  17.  
  18. }
  19.  
  20. </style>
  21.  
  22. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  23. <title>jsDatePick Javascript example</title>
  24.  
  25. <link rel="stylesheet" type="text/css" media="all" href="jsDatePick_ltr.min.css" />
  26. <!-- 
  27. OR if you want to use the calendar in a right-to-left website
  28. just use the other CSS file instead and don't forget to switch g_jsDatePickDirectionality variable to "rtl"!
  29.  
  30. <link rel="stylesheet" type="text/css" media="all" href="jsDatePick_ltr.css" />
  31. -->
  32. <script type="text/javascript" src="jquery.1.4.2.js"></script>
  33. <script type="text/javascript" src="jsDatePick.jquery.min.1.3.js"></script>
  34. <!-- 
  35. After you copied those 2 lines of code , make sure you take also the files into the same folder :-)
  36. Next step will be to set the appropriate statement to "start-up" the calendar on the needed HTML element.
  37.  
  38. The first example of Javascript snippet is for the most basic use , as a popup calendar
  39. for a text field input.
  40. -->
  41. <script type="text/javascript">
  42. window.onload = function(){
  43. new JsDatePick({
  44. useMode:2,
  45. target:"inputField",
  46. dateFormat:"%Y-%m-%d"
  47. /*selectedDate:{     This is an example of what the full configuration offers.
  48. day:5,     For full documentation about these settings please see the full version of the code.
  49. month:9,
  50. year:2006
  51. },
  52. yearsRange:[1978,2020],
  53. limitToToday:false,
  54. cellColorScheme:"beige",
  55. dateFormat:"%m-%d-%Y",
  56. imgPath:"img/",
  57. weekStartDay:1*/
  58. });
  59. };
  60. </script>
  61. <!-- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -->
  62. <title>Org Details</title> 
  63. </head> 
  64. <body> 
  65. <form method="post" action="insert5.php">
  66.  
  67. <h1>Insert the Following Details</h1>
  68. DATE: <input type="text" size="12" name="date" id="inputField" />
  69. <form method="post" action=""> 
  70. <table cellspacing="35">
  71. <tr><td><font face="verdana,arial" size=-1><Span><strong>Utilization:</strong></Span><td>
  72. <textarea rows="10" cols="50" name= "utilization">
  73.  
  74. </textarea>
  75. </td></tr>
  76. </table>
  77.  
  78. <table cellspacing="20">
  79. <tr><td><font face="verdana,arial" size=-1><Span><strong>Weekly Status:</strong></Span><td>
  80. <textarea rows="10" cols="50" name= "weekly_status">
  81.  
  82. </textarea>
  83. </td></tr>
  84. </table>
  85.  
  86.  
  87.  
  88. <table cellspacing="30">
  89. <tr><td><font face="verdana,arial" size=-1><Span><strong>DESUCCESS:</strong></Span><td>
  90. <textarea rows="10" cols="50" name= "desuccess">
  91.  
  92. </textarea>
  93. </td></tr>
  94. </table>
  95.  
  96.  
  97.  
  98. <table cellspacing="5">
  99. <tr><td><font face="verdana,arial" size=-1><Span><strong>ACCOMPLISHMENT:</strong></Span><td>
  100. <textarea rows="10" cols="50" name= "accomplishment">
  101.  
  102. </textarea>
  103. </td></tr>
  104. </table>
  105.  
  106.  
  107.  
  108. <table cellspacing="45">
  109. <tr><td><font face="verdana,arial" size=-1><Span><strong>ONCALL:</strong></Span><td>
  110. <textarea rows="10" cols="50" name= "oncall">
  111.  
  112. </textarea>
  113. <br><br> 
  114. <input type="submit" name="Submit" value="Submit"> 
  115. </form> 
  116. <?php 
  117.  
  118. ?> 
  119. </body> 
  120. </html> 
  121.  

INSERT.PHP

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. $con = mysql_connect("localhost","root","Oracle");
  4. if (!$con)
  5. {
  6. die('Could not connect: ' . mysql_error());
  7. }
  8.  
  9. mysql_select_db("test", $con);
  10.  
  11. $sql="INSERT INTO empinfo (orgdate, utilization, weekly_status, DE_sucess, accomplishment, oncall)
  12. VALUES
  13. ('$_POST[date]','$_POST[utilization]','$_POST[weekly_status]','$_POST[desuccess]','$_POST[accomplishment]','$_POST[oncall]')";
  14.  
  15.  
  16. if (!mysql_query($sql,$con))
  17. {
  18. die('Error: ' . mysql_error());
  19. }
  20. echo "1 record added";
  21.  
  22. mysql_close($con)
  23. ?> 
  24.  
Feb 22 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

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