473,405 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

PHP drop down list from MySQL database that will post to another table.

I am very new to PHP and am looking for some help with a problem that I am facing. I currently have a form which post to a table in MySQL.

At the moment all the fields (apart from date) have to be inputted manually.

I would like to be able to have a number of the fields as selection drop down boxes, populated from seperate tables in the database. This will aid the user and provide uniform data that can easily be analysed.

I have spent days trying to find the exact code to perform this task, so would be grateful if somebody has an answer for me.

Here is the code so far, (the fields I wish to have as drop down boxes are Model, Repair Carried Out & Work Source:

Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <script type="text/javascript" src="js/jquery.js" /></script>
  3.     <script type="text/javascript" src="js/jquery-ui.js" /></script>
  4. <script type="text/javascript" src="js/lisa.js" /></script>
  5.   <link href="css/jquery.css" media="screen" rel="stylesheet" type="text/css" />
  6.  
  7. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  8. <title>Untitled Document</title>
  9. <style type="text/css">
  10. <!--
  11. body {
  12.     margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
  13.     padding: 0;
  14.     text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
  15.     color: #000000;
  16.     font-family: Arial, Helvetica, sans-serif;
  17.     font-size: 100%;
  18.     background-color: #FFF;
  19. }
  20. .oneColFixCtrHdr #container {
  21.     width: 780px;  /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */
  22.     background: #FFFFFF;
  23.     margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
  24.     border: 1px solid #000000;
  25.     text-align: left; /* this overrides the text-align: center on the body element. */
  26. }
  27. .oneColFixCtrHdr #header {
  28.     padding: 0 10px 0 20px;  /* this padding matches the left alignment of the elements in the divs that appear beneath it. If an image is used in the #header instead of text, you may want to remove the padding. */
  29.     background-color: #FFF;
  30. }
  31. .oneColFixCtrHdr #header h1 {
  32.     margin: 0; /* zeroing the margin of the last element in the #header div will avoid margin collapse - an unexplainable space between divs. If the div has a border around it, this is not necessary as that also avoids the margin collapse */
  33.     padding: 10px 0; /* using padding instead of margin will allow you to keep the element away from the edges of the div */
  34. }
  35. .oneColFixCtrHdr #mainContent {
  36.     padding: 0 20px; /* remember that padding is the space inside the div box and margin is the space outside the div box */
  37.     background: #FFFFFF;
  38.     text-align: right;
  39. }
  40. .oneColFixCtrHdr #footer {
  41.     padding: 0 10px;
  42.     background-color: #FFF;
  43. }
  44. .oneColFixCtrHdr #footer p {
  45.     margin: 0; /* zeroing the margins of the first element in the footer will avoid the possibility of margin collapse - a space between divs */
  46.     padding: 10px 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */
  47. }
  48. -->
  49. </style>
  50.  
  51.  
  52. </head>
  53.  
  54. <body class="oneColFixCtrHdr">
  55.  
  56. <div id="container">
  57.   <div id="header">
  58.     <h1>Header</h1>
  59.   <!-- end #header --></div>
  60.   <div id="mainContent">
  61.     <form method="POST" action="download_pdf.php" name="input" onSubmit="return validate()">
  62.      <table width="70%" border="0" align="center">
  63.        <tr>
  64.          <td>Owners Name</td>
  65.          <td><input type="text" name="Owners_Name" /></td>
  66.        </tr>
  67.        <tr>
  68.          <td>Model </td>
  69.          <td><input type="text" name="Model" /></td>
  70.        </tr>
  71.        <tr>
  72.          <td>Reg No. </td>
  73.          <td><input type="text" name="Reg_No" /></td>
  74.        </tr>
  75.        <tr>
  76.          <td>Mileage </td>
  77.          <td><input type="text" name="Mileage" /></td>
  78.        </tr>
  79.        <tr>
  80.          <td>Repairs Carried Out </td>
  81.          <td><input type="text" name="Repairs_Carried_Out" /></td>
  82.        </tr>
  83.        <tr>
  84.          <td>Repair Date </td>
  85.          <td><input type="text" name="Repair_Date" id="Repair_Date" /></td>
  86.        </tr>
  87.        <tr>
  88.          <td>Invoice Number </td>
  89.          <td><input type="text" name="Invoice_Number" /></td>
  90.        </tr>
  91.        <tr>
  92.          <td>VIN (17 digits)</td>
  93.          <td><input type="text" name="VIN" /></td>
  94.        </tr>
  95.        <tr>
  96.          <td>Total Repair Cost </td>
  97.          <td><input type="text" name="Total_Repair_Cost" /></td>
  98.        </tr>
  99.        <tr>
  100.          <td>Paint Cost </td>
  101.          <td><input type="text" name="Paint_Cost" /></td>
  102.        </tr>
  103.        <tr>
  104.          <td>Labour Cost </td>
  105.          <td><input type="text" name="Labour_Cost" /></td>
  106.        </tr>
  107.        <tr>
  108.          <td>Parts Cost </td>
  109.          <td><input type="text" name="Parts_Cost" /></td>
  110.        </tr>
  111.        <tr>
  112.          <td>Work Source </td>
  113.          <td><input type="text" name="Work_Source" /></td>
  114.        </tr>
  115.      </table>
  116.      <br/>
  117.      <br/>
  118.       <input type="submit" value="Save" /></form> 
  119.  
  120.   <!-- end #mainContent --></div>
  121.   <div id="footer">
  122.     <p>Footer</p>
  123.   <!-- end #footer --></div>
  124. <!-- end #container --></div>
  125. </body>
  126. </html>
  127.  
May 5 '10 #1
1 2463
dlite922
1,584 Expert 1GB
Do you know how to connect and query a mysql DB from PHP?

If not click this: lmgtfy.com?q=PHP%20MySQL%20Tutorial

Let me know if you get stuck anywhere,






Dan
May 6 '10 #2

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

Similar topics

1
by: Jonny Tango | last post by:
Hello everyone. Q. How do I create a dynamically-generated drop-down list for use in an array. I'm using PHP with a MySQL database (through phpMyAdmin) My database table is called...
3
by: CJM | last post by:
Not sure if this is entirely on-topic.... I would ideally like to present an initial list based on one DB table. The user selects an item, and the 2nd list is updated to show items from the DB...
2
by: Robert Nurse | last post by:
Hi All, I'm trying to alter the contents of a drop-down (select) list on the parent window from a child window in IE 6. After opening the child window, I set its opener to reference the parent...
1
by: jcombalicer | last post by:
How will you make a drop down list that rely information from another drop down list with the help of row source, sql and query not with the of form, pages and vba. Every department has...
1
by: lewindha | last post by:
Hey guys I'm trying to populate a drop down list with values from a db table. When I view the page, the drop list is empty. Here is the code: private void populateClients() { string...
2
by: Eric Dan | last post by:
Hi, Even tough I was able to implement what I want in a weird and non efficient way, I would like to get an opinion what is the right way to achieve my task: Scenario: • Display a DataGrid...
1
by: bbdobuddy | last post by:
Hi, I have a problem that maybe you can help me with. I am pulling values from a database table and I don't know how to set the drop down list so it will show the specific value that I pulled...
0
by: jaeden99 | last post by:
I have a two drop down list box. The first contains district name(district id is the value) and the the second will contain the user name based on the district selected in the first drop down list....
1
by: deerick | last post by:
Hi there I want to know how to add a drop down list based on value from a table in an asp form. Then I want the user to be able to submit the form, and the drop down list value that they have...
3
by: maminx | last post by:
I have this script... var td = document.createElement('td'); var p = document.createElement('p'); var label = document.createElement('label'); var span =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
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...

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.