Jump to content

Archived

This topic is now archived and is closed to further replies.

Prank

problems with select statement

Recommended Posts

Hi Guys,

I am having a brain fart and cant seem to work out how to do this....

My 2 tables;

[code]phones_man
+-------+--------------+------+-----+---------+----------------+
| Field   | Type           | Null | Key | Default | Extra            |
+-------+--------------+------+-----+---------+----------------+
| id       | int(11)        |         | PRI | NULL    | auto_increment |
| name  | varchar(100) |      |       |            |                     |
+-------+--------------+------+-----+---------+----------------+

phones_mod
+--------+--------------+------+-----+---------+----------------+
| Field    | Type          | Null   | Key | Default | Extra            |
+--------+--------------+------+-----+---------+----------------+
| id        | int(11)        |         | PRI | NULL    | auto_increment |
| name   | varchar(100) |      |       |            |                      |
| man_id | int(100)     |         |       | 0         |                      |
+--------+--------------+------+-----+---------+----------------+[/code]


Ok, what I am trying to do is populate a drop down box using the results from phones_man and then populating the 2nd drop down box with the models that match the manufacturer selected in the first box.

Does that make sense?

The other alternative is to have 1 box list all the manufacturers and models like such;
man1_mod1
man1_mod2
man1_mod3
man2_mod1
man2_mod2

etc...

Either is fine, the first method would probably utilise a javascript auto form submit to populate the 2nd box i would think..

Either way, Advice needed. :)

Thanks very much.

Christian

edit - damn whitespace is ignored... there goes that formatting :(
mod edit: use [code] and your whitespaces are back :)

Share this post


Link to post
Share on other sites
You'd have to use JavaScript either way, unless you're going to go the IFRAME/XMLHttpRequest route. And since that's the case, it makes sense simply to output both tables to a JS array, and then have one drop-down update the other. There are many tutorials on how to accomplish this.

From a MySQL standpoint, this is trivial, since you're getting back all the rows.

Share this post


Link to post
Share on other sites
[!--quoteo(post=346493:date=Feb 17 2006, 06:54 AM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Feb 17 2006, 06:54 AM) [snapback]346493[/snapback][/div][div class=\'quotemain\'][!--quotec--]
You'd have to use JavaScript either way, unless you're going to go the IFRAME/XMLHttpRequest route. And since that's the case, it makes sense simply to output both tables to a JS array, and then have one drop-down update the other. There are many tutorials on how to accomplish this.

From a MySQL standpoint, this is trivial, since you're getting back all the rows.
[/quote]


Awesome, thanks - I did end up using javascript but its so messy and I hate messy code.

Anyhoo, thanks again.

Share this post


Link to post
Share on other sites
Glad you got it working. Don't take this the wrong way, but if it's messy, it's usually incorrect -- you may want to find a better tutorial / source code example. Off the top of my head, you should be able to do it in under 10 lines of JS code.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.