hi, new in the forum and to php, my question is the following.
I have several groups of students with between 20 to 30 students in each group

I want to make a code to select a group to separate the students by group right know I have this.. (in two days of searching....) really!!

echo "<select name='Grupo' id='Grupo' onchange='selected()'>";

$defaultgrp = 10423;

$Group=mysql_query("SELECT * FROM group where type = 1",$con);

while($group=mysql_fetch_array($Group)){
$select = ($row["classPK"] == $defaultgrp ? "selected" : "");
echo("<option value= ".$group["classPK"]." > ".$group["name"]." </option>");
}
echo "</select>";

How Do I get the selected option from here to a variable like $GroupID = $selected
in order to make the query for students from the selected group..

thanks in advance.

    You almost had it. You need to echo the value into the <select> tag for it to work. This oughta be it, cleaned up and formatted . . .

    while( $group=mysql_fetch_array($Group) ) {
    	$select = $row["classPK"] == $defaultgrp ? ' selected="selected"' : '';
    	echo "<option value=\"{$group['classPK']}\" $select>{$group['name']}</option>";
    }
    
      Write a Reply...