473,507 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

To access the data from database when select the value in dropdown menu

99 New Member
Hi to all, i m newer to this site and fresher in Ajax world. Actually i get a problem while accessing data from Database. I have a combo box in my pages. Actually i want to access data from the database and put in a form variable as soon as when i select the name in the combo box. For more details i m giving the code below..
this is my first pages: empAttedence.php
Expand|Select|Wrap|Line Numbers
  1. <table width="100%" cellpadding="2" cellspacing="1">
  2.  
  3. <form name="attendence" method="post" action="attendence.php">
  4. <tr >
  5. <td align="left" width="40%">
  6.     Employee Name:
  7. </td>
  8. <td align="left">
  9. <?php 
  10.  
  11.  
  12.         $empDepartment = $_GET['empDepartment'];
  13.  
  14.         $sql1 = "SELECT * FROM employee WHERE empDepartment='$empDepartment'";
  15.         $result = mysql_query($sql1) or die(mysql_error());
  16. ?>
  17.     <select name="empFirstName">
  18. <?php
  19.         while($rows = mysql_fetch_array($result))
  20.  
  21.         {
  22. ?>
  23.  
  24.         <option value="<?php echo $rows['empFirstName']; ?>"><?php echo $rows['empFirstName']; ?></option>
  25.  
  26. <?php
  27.         }
  28. ?>
  29. </select>
  30. <?php 
  31.     $sql1 = "SELECT * FROM employee WHERE empDepartment='$empDepartment'";
  32.     $result = mysql_query($sql1) or die(mysql_error());
  33.     $rows = mysql_fetch_array($result) or die(mysql_error());
  34. ?>
  35. <input type="hidden" value="<?php echo $rows['empId']; ?>" name="empId">
  36. <input type="hidden" value="<?php echo $rows['empDepartment']; ?>" name="empDepartment">
  37. <input type="hidden" value="<?php echo $rows['empLastName']; ?>" name="empLastName">
  38.  
  39. </td>
  40. </tr>
  41. <tr>
  42.     <td align="left">Date:</td>
  43.     <td align="left"><input type="text" value="<?php echo date("Y-m-d");?>" name="empAttendenceDate" size="10">&nbsp&nbsp(YYYY-MM-DD)</td>
  44. </tr>
  45. <tr>
  46.     <td align="left">
  47.         In-Time:
  48.     </td>
  49.     <td align="left">
  50.         <input type="text" name="empInTime" size="10">&nbsp (9.30)
  51.     </td>
  52. </tr>
  53. <tr>
  54.     <td align="left">
  55.         Out-Time:
  56.     </td>
  57.     <td align="left">
  58.         <input type="text" name="empOutTime" size="10"> &nbsp(6.30)
  59.     </td>
  60. </tr>
  61. <tr>
  62.     <td></td>
  63.     <td align="left"><input type="submit" value="Submit" name="submit">&nbsp&nbsp<input type="reset" value="Reset" name="reset"></td>
  64. </tr>
  65.  
  66. </form>
  67. </table></b>
  68. Actually when I select the name in 
  69. <select name="empFirstName">
  70. <?php
  71.         while($rows = mysql_fetch_array($result))
  72.  
  73.         {
  74. ?>
  75.  
  76.         <option value="<?php echo $rows['empFirstName']; ?>"><?php echo $rows['empFirstName']; ?></option>
  77.  
  78. <?php
  79.         }
  80. ?>
  81. </select>
the data in the row should access automatically through ajax. Plz if you know then please help as soon as possible. I want to pass the other data through other pages as hidden value. Thanking you and waiting for you reply
Oct 16 '07 #1
1 1850
acoder
16,027 Recognized Expert Moderator MVP
The PHP code that retrieves the data should be put in a separate file. This should then be called via AJAX. See an example.
Nov 3 '07 #2

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

Similar topics

1
3347
by: djharrison | last post by:
I'm new to ASP and database programming but I am trying to connect to a database using a concatenation of a strings and a menu item from a form. Ok here's what I have... an asp form that has a...
1
9991
by: Rod Early | last post by:
I need to know when the select element's dropdown list is opened (as when the user clicks on the arrow or does ALT-downarrow from the keyboard). Similarly, I need to known when the dropdown list...
4
2054
by: Odin | last post by:
Hello I am making a webpage with two dropdown menus. First I have a dropdown menu with a list of 235 countries. When one country is selected from this list the contents of the next dropdown menu...
13
3959
by: royaltiger | last post by:
I am trying to copy the inventory database in Building Access Applications by John L Viescas but when i try to run the database i get an error in the orders form when i click on the allocate...
27
45488
by: Wayne | last post by:
I've been clicking around Access 2007 Beta 2 and can't see the custom menu bar designer. Is it in the beta? Maybe I'm blind. The question that comes to mind is: Will custom menu bars be the same...
3
2139
by: Eric Layman | last post by:
HI, I have a select menu <select id="country" runat="server" class="myformat "> <option value="AFGHANISTAN">AFGHANISTAN</option> <option value="ALBANIA">ALBANIA</option>
1
2308
akhan
by: akhan | last post by:
i used the following code to enter data in dropdown menu : <? $con=mysql_connect("","",""); mysql_select_db('investment',$con); $query="select *from personal_info"; $res =...
5
3973
by: giandeo | last post by:
Hello Experts. Could you find a solution for this problem please! I have the following tables in Access Database Table Name: origin Fields Names: country, countrycode Table Name: make...
2
19403
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
7319
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
7031
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
5623
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,...
1
5042
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...
0
4702
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
3191
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
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
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...

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.