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

Combo box selection

P: 27
Hi
I have a department table which consists of dept_id and dept_name.I have an Employee table in which dept_id is the foreign key.In the form i am displaying the department names from department table in a combo box using php code.Even if display of combobox is department name the inserted value should be dept_id which is the foreign key.How can i insert in that way. [PHP]
<tr>
<td>Department</td>
<td><select name="dept_id">
<?php
$qury_disp="SELECT * from department order by dept_id asc"; $result_disp=pg_query($qury_disp);
$numrows=pg_numrows($result_disp);
while($row=pg_fetch_array($result_disp)) {
// echo "<option>$row[0]</option>";
echo "<option>$row[1]</option>";
}
echo "</select>\n";
?>
[/PHP]

Anyone please help
Sep 11 '08 #1
Share this Question
Share on Google+
4 Replies


Atli
Expert 5K+
P: 5,058
You mean:
Expand|Select|Wrap|Line Numbers
  1. <option value="ID">Name</option>
  2.  
Sep 11 '08 #2

P: 27
Thank You
It is working now.
can I populate a combo box for section which has got dept_id,section_id and section_name fields in section table.That is when i select a particular department only the sections coming under that department should appear in the combo box.
Plz help me.
Sep 11 '08 #3

10K+
P: 13,264
Thank You
It is working now.
can I populate a combo box for section which has got dept_id,section_id and section_name fields in section table.That is when i select a particular department only the sections coming under that department should appear in the combo box.
Plz help me.
Use AJAX.
Sep 11 '08 #4

P: 27
HI
Thank u for the suggestion but I dont want to use ajax.I know it is possible in Php .
Plz tell me how to popoulate a sectionfield in combo box when a particular department is selected.I tried it but only department is displayed the other doesnt work.Plz tell me how to write the query for this subselection.Plz help .
Sep 17 '08 #5

Post your reply

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