Jump to content

Reading a sql table, and putting it into a double "select" dropbox by id.. how??


physaux

Recommended Posts

Ok guys, I'm stuck at this little problem

 

Everything up to reading in the data is fine, I am reading in my data in a function like this:

 

<?php

<form method="POST" action="index.php?id1=admin&id2=edit">
$returnvalue['content']='
User by Title: <select name="id" size="1">
';


$query = "SELECT * FROM db_name";
$result = mysql_query($query, $connection);
if(!$result){
	echo "FAIL";	
}
while($row = mysql_fetch_array($result))
{	
	$returnvalue['content'].='<option value="'.$row["id"].'">'.$row["title"].'</option>';
}

$returnvalue['content'].='</select><br> <input type="submit" value="Edit this member"> </p>

?>

 

 

Now this is fine, and it works. But the list is crazy long! I want to have a "double dropdown", where the first dropdown would select the "class", and then the second dropdown would only show the names that have the same "class".

:o

My database has the following fields

id- unique

class- common

title- unique

 

How could I go about breating a double dropdown, where the second list depends on the first lists choice? Any help?

a few ways i can think of.

 

1. have a javascript on select fire an ajax request to pull in the next drop down

2. make it a step process, once the user selects the class they have to hit submit, the page reloads and has the 2nd drop down with only the options corresponding to the first drop down.

3. render out all of the 2nd drop down possibilities and display:none; on them. then on select have a javascript function display:block; on the corresponding drop down menu.

Archived

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

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