Hello friends
i have 2 list in my form 1. Employee Type and 2. Designation in first
list (1. Employee Type) i have 3 valuse 2,3,4 ....for designation field
i ahve a table DESIG .....I want output in such a way that when i select
employee==2 .....it should show the related designation from table and when
i select employe_type==3 it should show the designation related to that types of employees
in DESIG table i have two columns
employ_type || designation
2 LECT
2 ASOP
3 LEST
3 PLOC
4 IPCK
etc........i am getting these designation values from database but now i do not know how to send these values to the designation list(i mean loop or somting else)
can anybody suggest me how to code for this so that i can link those two lists
prroblem of linking lists
Moderator: General Moderators
-
om.bitsian
- Forum Commoner
- Posts: 36
- Joined: Wed Sep 09, 2009 4:13 am
prroblem of linking lists
- Attachments
-
- payentry.zip
- (5.66 KiB) Downloaded 43 times
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Re: prroblem of linking lists
Something like this: SELECT employeeType, employeeDesignation FROM employee, designation WHERE employeDesignation = designationId;
Or you could use a join.
Or you could use a join.
-
om.bitsian
- Forum Commoner
- Posts: 36
- Joined: Wed Sep 09, 2009 4:13 am
Re: prroblem of linking lists
with quary i am ok....
$query = "SELECT DESIG from desig WHERE EMP_TYPE=2";
$result = mysql_query($query) or die ("Error in query: $query");
$row = mysql_result($result,0,"DESIG");
now this result i have to send to the other list disignation....
<label >9. Designation</label></select>
can you please tell me how can i post the result of quary into the designation list
(coding part.......so that only emplyee type -2 , designation appear in the list)
$query = "SELECT DESIG from desig WHERE EMP_TYPE=2";
$result = mysql_query($query) or die ("Error in query: $query");
$row = mysql_result($result,0,"DESIG");
now this result i have to send to the other list disignation....
<label >9. Designation</label></select>
can you please tell me how can i post the result of quary into the designation list
(coding part.......so that only emplyee type -2 , designation appear in the list)
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Re: prroblem of linking lists
You're very difficult to understand. What are these lists you speak of?
Try:
2 or -2? I think you mean 2.so that only emplyee type -2 , designation appear in the list
Try:
Code: Select all
$q = "SELECT * FROM desig WHERE EMP_TYPE = 2";
$result = mysql_query($q) or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
$rowDump = var_dump($row);
echo "<pre>$rowDump</pre><br />";
}-
om.bitsian
- Forum Commoner
- Posts: 36
- Joined: Wed Sep 09, 2009 4:13 am
Re: prroblem of linking lists
values are coming in the valriable $rowDump (last post) but still the designation list is blank.......please check the both list and suggest me how to solve this problem
last post: while($row = mysql_fetch_assoc($result)) {
$rowDump = var_dump($row);
echo "<pre>$rowDump</pre><br />";
$desg=($_POST['rowDump']); }
this is the form code:
<label>3. Employee Type</label>
<select name="emptyp">
<option value="2">2 (Teaching faculty)</option>
<option value="3">3 (Supporting staff)</option>
<option value="4">4 (Helping staff)</option>
</select>
<label >9. Designation</label>
<select name="desg" value="desg" > </select><br><br>
last post: while($row = mysql_fetch_assoc($result)) {
$rowDump = var_dump($row);
echo "<pre>$rowDump</pre><br />";
$desg=($_POST['rowDump']); }
this is the form code:
<label>3. Employee Type</label>
<select name="emptyp">
<option value="2">2 (Teaching faculty)</option>
<option value="3">3 (Supporting staff)</option>
<option value="4">4 (Helping staff)</option>
</select>
<label >9. Designation</label>
<select name="desg" value="desg" > </select><br><br>
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Re: prroblem of linking lists
You never answered me question on what a list is but I managed to glean it from your example. For future reference, you should describe these things as one of the following: combo-box, select field, or drop-down menu. Any of those work. List, on the other hand, is very generic and generally meaningless in the context of software.
Also, whilst I'm correcting your language; it's query, not quary.
Also, whilst I'm correcting your language; it's query, not quary.
You need to generate the HTML. Replace my var_dump() with output of an option tag (using echo or something). I'm not going to do it for you but post back if you have difficulty.but still the designation list is blank.......please check the both list and suggest me how to solve this problem