help from selecting from list

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
om.bitsian
Forum Commoner
Posts: 36
Joined: Wed Sep 09, 2009 4:13 am

help from selecting from list

Post by om.bitsian »

hi all
i have two lists 1. Employee type(1,2,3) and 2. designation(around 50)
i want somthing like if (employee tpye==1) so it should show some designation which come under this type from designation list i.e
LECT, ASST, PROF etc

if (employee tpye==2) it should show some other designation from designation list i.e
PA, JOAT,JAAT etc.....

if (employee tpye==3) it should show only the designation which come under this perticular employee type ...
is it possible in php.....

thanks
User avatar
Weiry
Forum Contributor
Posts: 323
Joined: Wed Sep 09, 2009 5:55 am
Location: Australia

Re: help from selecting from list

Post by Weiry »

Where abouts are you storing your employee types?
Also, is there something somewhere that defines which employee types are related to a designation?
such as..
Employee type 1 -> has relation to -> LECT / PROF
Employee type 2 -> has relation to -> ASST
om.bitsian
Forum Commoner
Posts: 36
Joined: Wed Sep 09, 2009 4:13 am

Re: help from selecting from list

Post by om.bitsian »

i am storing EMP_TYPE(1,2,3) in "major" table and in the same table i am having other column DESIG.......DESIG list contain (LECT,PROF,JOAT....etc)

now i want to seperate employee by their designation....
so shall i create new table in that i can write DESIG and emplyee type to link then

out put : when i select employee type 1 than in the DESIGNATION list it should show only the values come uder employye type 1.....it should not show other designation
User avatar
Weiry
Forum Contributor
Posts: 323
Joined: Wed Sep 09, 2009 5:55 am
Location: Australia

Re: help from selecting from list

Post by Weiry »

Ok so from my understanding, each variation in your table will look something like this

Code: Select all

 
[u]EMP_TYPE  |  DESIG  [/u]
    1     |  LECT
    1     |  PROF
    2     |  ASST
 
A simple query such as:

Code: Select all

$query = "SELECT `DESIG`,`EMP_TYPE` FROM `MAJOR` WHERE `EMP_TYPE` = '{$employee_type}'";
all you would need to do, is send the $employee_type through a form to the page where the query will be executed.

from there to print all types, you would just do a simple while loop:

Code: Select all

 
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
print "Employee Type: {$row['EMP_TYPE']} has the following designations:<br/>";
while($row){
   print "{$row['DESIG']} , ";
}
 
something like that should print the designations for the specified employee type
Post Reply