Jump to content


Photo

**SOLVED** combo box help !!


  • Please log in to reply
18 replies to this topic

#1 devofash

devofash
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 12 April 2006 - 06:19 PM

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 example

sorry 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

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 12 April 2006 - 07:53 PM

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]
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 devofash

devofash
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 12 April 2006 - 08:09 PM

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 ... ?

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 12 April 2006 - 09:27 PM

The baaSelect class will write the required js code for you

All you need is

<?php
include '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>


If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#5 devofash

devofash
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 12 April 2006 - 09:53 PM

oo cool....... it works.... :)

but its not exactly what i want though :( ...... soz i think its sorta my fault prob. didnt explain everything properly

ermm 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.....



#6 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 12 April 2006 - 09:57 PM

.... basically if a user clicks on "Human Resources", i want the combo box to list all the jobs in that department => "clerk" and "manager".

Above is extract from your first post.

So what output do you want?
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#7 devofash

devofash
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 12 April 2006 - 10:03 PM

sorry ... i sorta ment that ... i'll start again

when 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......



#8 devofash

devofash
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 13 April 2006 - 01:20 AM

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 :)

#9 devofash

devofash
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 13 April 2006 - 01:44 PM

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 ....

      <form name = 'form' method='GET' action=display_jobs.php >

      <form name = 'form' method='GET' action= <? ?page=display_jobs ?> >

^^ but when i do this it doesnt work. i need to use this method instead of the first one

can anyone help ... plz ......


thanx

#10 devofash

devofash
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 13 April 2006 - 03:36 PM

anyone !

#11 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 13 April 2006 - 11:06 PM

[!--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?

<form name = 'form' method='GET' action='?page=display_jobs'>

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#12 devofash

devofash
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 14 April 2006 - 08:51 PM

[!--quoteo(post=364625:date=Apr 14 2006, 12:06 AM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Apr 14 2006, 12:06 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Why is the action in php tags when there is no php code?

<form name = 'form' method='GET' action='?page=display_jobs'>
[/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

#13 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 14 April 2006 - 10:17 PM

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]but instead i need to do '?page=display_jobs'.[/quote]

Why?
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#14 devofash

devofash
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 14 April 2006 - 10:19 PM

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.

#15 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 14 April 2006 - 10:43 PM

?page=display_jobs

will return you to the same page with "display_jobs" in $_GET['page']

But you aren't doing anything with $_GET['page'] in the script !
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#16 devofash

devofash
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 14 April 2006 - 10:55 PM

i have an index page where i've got somethin like this

$page = $_GET['page']
switch($page)
{
  case "display_jobs":
  include('display_jobs.php');
  break;
}

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

#17 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 14 April 2006 - 11:09 PM

Then the form action needs to be something like

action='index.php?page=display_jobs'

But you will also need a way of passing the selected department.


If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#18 devofash

devofash
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 14 April 2006 - 11:20 PM

action='index.php?display_jobs&department=$id'

is that it... but its not working either

soz this is very embarassing but how do i do that....? ..... dont get combo boxes shoul've never used it in the first place

#19 devofash

devofash
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 15 April 2006 - 10:13 PM

i've done it ........ was really tired yesterday ..... couldnt think properly........

thread SOLVED ....... thanx once again barand for all the help :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users