devofash Posted April 12, 2006 Share Posted April 12, 2006 hey guys ... how's it going ?? newbie here got a question ..... need a little help with combo box, here's what i need the combo box to do. Firstly i have 2 tables "jobs" and "department". A job in jobs table has a reference no. which refers to a department id in the department table. i'll give an examplesorry not very good at explaining hope i'm making sense so far. right i need the combo box to list all the department names (i've done that already, u'll c the code below).... basically if a user clicks on "Human Resources", i want the combo box to list all the jobs in that department => "clerk" and "manager".hope u guys can help me out :D.... thanx Quote Link to comment https://forums.phpfreaks.com/topic/7236-solved-combo-box-help/ Share on other sites More sharing options...
Barand Posted April 12, 2006 Share Posted April 12, 2006 To make life easier, try the baaSelect link in my sig, or use [a href=\"http://members.aol.com/barryaandrew/xmlhttp/article.html\" target=\"_blank\"]xmlhttp request[/a] Quote Link to comment https://forums.phpfreaks.com/topic/7236-solved-combo-box-help/#findComment-26362 Share on other sites More sharing options...
devofash Posted April 12, 2006 Author Share Posted April 12, 2006 phew.... i'm quite a newbie to all this can hardly do simple stuff ... the links u mentioned looks quite complicated. dont really know any jscript either, can it not be done with just plain php ... ? Quote Link to comment https://forums.phpfreaks.com/topic/7236-solved-combo-box-help/#findComment-26367 Share on other sites More sharing options...
Barand Posted April 12, 2006 Share Posted April 12, 2006 The baaSelect class will write the required js code for youAll you need is[code]<?phpinclude 'baaselect.php';include 'db.php'; #database connection$sel = new baaSelect();$sel->addSelect('department', 'department', 'dept_id', 'department','',BY_TEXT,'--select department--');$sel->addSelect('job', 'jobs', 'jobid', 'jobTitle','department',BY_TEXT,'--select job--');?><HTML><HEAD><meta Name="generator" content="PHPEd Version 3.1.2 (Build 3165)"><title>Sample</title><? $sel->makeScript(); ?></HEAD><BODY><form method=get><?$sel->makeSelect('department'); # this creates the HTML$sel->makeSelect('job');?></form></BODY></HTML>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/7236-solved-combo-box-help/#findComment-26391 Share on other sites More sharing options...
devofash Posted April 12, 2006 Author Share Posted April 12, 2006 oo cool....... it works.... :)but its not exactly what i want though :( ...... soz i think its sorta my fault prob. didnt explain everything properlyermm right now it displays all the department (click department and it displays all the jobs in that department) ...... but i dont want the jobs to be displayed in another combo ..... i need it to display it in an page... with some other job details..... Quote Link to comment https://forums.phpfreaks.com/topic/7236-solved-combo-box-help/#findComment-26398 Share on other sites More sharing options...
Barand Posted April 12, 2006 Share Posted April 12, 2006 .... basically if a user clicks on "Human Resources", i want the [b]combo box[/b] to list all the jobs in that department => "clerk" and "manager".Above is extract from your first post.So what output do you want? Quote Link to comment https://forums.phpfreaks.com/topic/7236-solved-combo-box-help/#findComment-26401 Share on other sites More sharing options...
devofash Posted April 12, 2006 Author Share Posted April 12, 2006 sorry ... i sorta ment that ... i'll start againwhen a user clicks human resources, i want the combo box to display all the job details of the clerk and manager in a page (the jobs table has other fields) need them to be displayed too ...thanx in advance for the help...... Quote Link to comment https://forums.phpfreaks.com/topic/7236-solved-combo-box-help/#findComment-26403 Share on other sites More sharing options...
devofash Posted April 13, 2006 Author Share Posted April 13, 2006 hmm solved......i just passed the value to another query .... used get to get the value....ran a query on that value and displayed the matching records :) ............. cant believe i didnt thing of tht before... it just didnt crosss my mind :duh:thanx barand........ apreciate ur help :) Quote Link to comment https://forums.phpfreaks.com/topic/7236-solved-combo-box-help/#findComment-26439 Share on other sites More sharing options...
devofash Posted April 13, 2006 Author Share Posted April 13, 2006 dont want to make another thread .... just need a little help with somethin ... its related to this topic so... here goes. the script listed at the end ... works fine .... except for one little problem .. the problem:when i do this it works fine ....[code] <form name = 'form' method='GET' action=display_jobs.php >[/code][code] <form name = 'form' method='GET' action= <? ?page=display_jobs ?> >[/code]^^ but when i do this it doesnt work. i need to use this method instead of the first onecan anyone help ... plz ......thanx Quote Link to comment https://forums.phpfreaks.com/topic/7236-solved-combo-box-help/#findComment-26588 Share on other sites More sharing options...
devofash Posted April 13, 2006 Author Share Posted April 13, 2006 anyone ! Quote Link to comment https://forums.phpfreaks.com/topic/7236-solved-combo-box-help/#findComment-26638 Share on other sites More sharing options...
Barand Posted April 13, 2006 Share Posted April 13, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<form name = 'form' method='GET' action= <? ?page=display_jobs ?> >[/quote]Why is the action in php tags when there is no php code?[code]<form name = 'form' method='GET' action='?page=display_jobs'>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/7236-solved-combo-box-help/#findComment-26803 Share on other sites More sharing options...
devofash Posted April 14, 2006 Author Share Posted April 14, 2006 [!--quoteo(post=364625:date=Apr 14 2006, 12:06 AM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Apr 14 2006, 12:06 AM) [snapback]364625[/snapback][/div][div class=\'quotemain\'][!--quotec--]Why is the action in php tags when there is no php code?[code]<form name = 'form' method='GET' action='?page=display_jobs'>[/code][/quote]still doesnt work. if i put <form action = 'display_jobs.php'> it works perfectly..... but need to use QUERY_STRING so have to put <form action = '?page=display_jobs'> ...... but still doesnt work ... so dont know wth to do ...?basicallly all i need to do is get data from a database table into the combo box, when user clicks a record .... alll the data related to that record is displayed into a page. i.e.... user picks "Human Resources" presses submit... all the jobs from tht department is displayed into another page. script works if i put 'display_jobs.php' but instead i need to do '?page=display_jobs'.... any help will be appreicated :D .......also i would much appreciate it if someone can tell me if the above posted code can be made better or if there's a shorter way of doing what i've done. thanx in advance Quote Link to comment https://forums.phpfreaks.com/topic/7236-solved-combo-box-help/#findComment-27068 Share on other sites More sharing options...
Barand Posted April 14, 2006 Share Posted April 14, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]but instead i need to do '?page=display_jobs'.[/quote]Why? Quote Link to comment https://forums.phpfreaks.com/topic/7236-solved-combo-box-help/#findComment-27098 Share on other sites More sharing options...
devofash Posted April 14, 2006 Author Share Posted April 14, 2006 because in all the other pages that i've got i've done that.... need to stay consistent..... and i thought using the query_string thing was efficient. Quote Link to comment https://forums.phpfreaks.com/topic/7236-solved-combo-box-help/#findComment-27100 Share on other sites More sharing options...
Barand Posted April 14, 2006 Share Posted April 14, 2006 ?page=display_jobswill return you to the same page with "display_jobs" in $_GET['page']But you aren't doing anything with $_GET['page'] in the script ! Quote Link to comment https://forums.phpfreaks.com/topic/7236-solved-combo-box-help/#findComment-27109 Share on other sites More sharing options...
devofash Posted April 14, 2006 Author Share Posted April 14, 2006 i have an index page where i've got somethin like this[code]$page = $_GET['page']switch($page){ case "display_jobs": include('display_jobs.php'); break;}[/code]but dont c wht that one has to do with this script... ? ... how do i get this one to work.. sorie i'm being really silly just get very frustrated when my code dont work and i start being dumb :S Quote Link to comment https://forums.phpfreaks.com/topic/7236-solved-combo-box-help/#findComment-27112 Share on other sites More sharing options...
Barand Posted April 14, 2006 Share Posted April 14, 2006 Then the form action needs to be something like[code]action='index.php?page=display_jobs'[/code]But you will also need a way of passing the selected department. Quote Link to comment https://forums.phpfreaks.com/topic/7236-solved-combo-box-help/#findComment-27114 Share on other sites More sharing options...
devofash Posted April 14, 2006 Author Share Posted April 14, 2006 action='index.php?display_jobs&department=$id'is that it... but its not working eithersoz this is very embarassing but how do i do that....? ..... dont get combo boxes shoul've never used it in the first place Quote Link to comment https://forums.phpfreaks.com/topic/7236-solved-combo-box-help/#findComment-27116 Share on other sites More sharing options...
devofash Posted April 15, 2006 Author Share Posted April 15, 2006 i've done it ........ was really tired yesterday ..... couldnt think properly........ thread SOLVED ....... thanx once again barand for all the help :) Quote Link to comment https://forums.phpfreaks.com/topic/7236-solved-combo-box-help/#findComment-27338 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.