Jump to content

Recommended Posts

Hi,

 

I wonder whether someone may be able to help me please. I'm very new to PHP so please bear with me.

 

I have a three tables in MySQl database called 'userdetails' 'detectors' and 'detectorsearchheads' with the following fields:

 

userdetails

userid

username

 

detectors

userid

detectorid

detectordescription

 

detectorsearchheads

userid

detectorid

detectorsearchheadid

detectorsearchheaddescription

 

What I would like to do, if at all possible, is to have the first drop down for detectors which is user specific (i.e pertinent to the current users records) and then another dropdown menu which is again user specific but will then will only show the values pertinent to the value of the first drop down menu. But I must admit I haven't a clue where to start.

 

Would be at all posssible please that someone could give me a little bit of help to start me off with this.

 

Many thanks and regards

I've coded this a few times but I'm not sure if there is a better way to do it. This is how I did it:

 

Use PHP to pull all the values from the database and put them into 3 separate arrays, there are lots of tutorials around for this. Populate the first SELECT box with the proper values and attach an onchange function to it to call Javascript. Inside your Javascript, you'll grab the other SELECT box by its ID and inject the proper values into it.

 

If I confused you, this might be a little too advanced for you.

Both,

 

Many thanks for replying to my post. As I said I am fairly new to this, so I'm not too sure how I would go about implementing the first method proposed at the moment.

 

I am however using Dreamweaver. I was aware that there was this functionality available, but I found the help files pretty poor. Could you perhaps please elaborate as to how I woudl go about doing this.

 

Many thanks and regards

 

Chris

Create a RECORDSET FOR THE PARTICULAR VALUE YOU NEED TO DISPLAY IN THE DROP DOWN MENU

THEN

SELECT THE DROP DOWN MENU AND SEE IN PROPERTIES THERE YOU'LL FIND THE OPTION OF DYNAMIC VALUES

CLLICK ON IT

THEN SET YOUR RECORDSET TO IT

AND GET IT DONE

ITS THAT SIMPLE...

Hi,

 

I've been working on this over the last few days and I've finally got my first drop down menu to work.

 

I'm now unsure about how to progress this by adding another drop down menu with the values shown dependent on the users choice in the first drop down menu.

 

Here is the code I am using:

 

<?php
                        mysql_connect("hostname", "username", "password") or die("Connection Failed");
                        mysql_select_db("databasename")or die("Connection Failed");
                        $query = "SELECT * FROM detectors WHERE `userid` = '1' ORDER BY 'detectorname' ASC";
                        $result = mysql_query($query);
                        ?>
                        <select name="detectorname">
                            <?php
                            while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
                            ?>
                            <option value="<?php echo $line['detectorname'];?>"> <?php echo $line['detectorname'];?> </option>
                            
                            <?php
                            }
                            ?>
                        </select> 

 

 

What I'd now like to be able to do is to only show those values in the second drop down menu from the table 'searchheads' where the 'detectorid' is the same as that chosen in the first drop down menu which is populated from the table 'detectors'.

 

I just wondered whether it would be at all possible please that someone could show me how I would go about doing this.

 

Many thanks and regards

 

Chrid

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.