hi
plz help me,
i have a code in which two multiple selection dropdown list. in first list if I am select single value the data are fetch in second table on button click. but the problem is in first dropdown list the second field is also select after the page submit.
the code is
[php] <?php
include("connec t.php");
?>
<html><body>
<form name="check" method="post" >
<select name="proj_type[]" style="width: 120px" size="3" multiple="multi ple">
<?php
$var=$_POST['proj_type'];
$firstcon=1;
$seccon=1;
if (!$var=="")
{
foreach( $var as $cat)
{
if ($firstcon== 1)
{
if ($cat="1")
{
$firstcon=2;
?>
<option selected value="1">Desig ning</option>
<?php
}
else
{
$firstcon=2;
?>
<option value="1">Desig ning</option>
<?php
}
}
if ($seccon== 1)
{
if ($cat="2")
{
$seccon=2;
?>
<option selected value="2">Progr amming</option>
<?php
}
else
{
$seccon=2;
?>
<option value="2">Progr amming</option>
<?php
}
}
}
}
else
{
?>
<option value="1">Desig ning</option>
<option value="2">Progr amming</option>
<?php
}?>
</select>
<?php
if(isset($_POST['S']))
{
$str="";
$var=$_POST['proj_type'];
foreach( $var as $cat)
{
if ($str=="")
{
$str=$cat;
}
else
{
$str=$str.",".$ cat;
}
}
}
echo $str;
?>
<select name="skill_typ e[]" style="width:12 0px" size="3" multiple="multi ple" >
<?php
if(isset($_POST['S']))
{
$skill=$_POST['proj_type'];
$str="";
foreach($skill as $cat)
{
if ($str=="")
{
$str=$cat;
}
else
{
$str=$str.",".$ cat;
}
$secondQry = "select * from skill_set where skill_type = '".$cat."'";
$sql = mysql_query($se condQry ) or die(mysql_error ());
while($row = mysql_fetch_ass oc($sql))
{
?>
<option selected value="<?php echo $row['skill_id'];?>"><?php echo $row['skill_name'];?></option>
<?php
}
}
}
?>
</select>
<input type="submit" name="S" value="Submit" id="Submit" >
</form>
</body>
</html>[/php]
Please enclose any code within the proper code tags. See the Posting Guidelines on how to do that.
MODERATOR
plz help me,
i have a code in which two multiple selection dropdown list. in first list if I am select single value the data are fetch in second table on button click. but the problem is in first dropdown list the second field is also select after the page submit.
the code is
[php] <?php
include("connec t.php");
?>
<html><body>
<form name="check" method="post" >
<select name="proj_type[]" style="width: 120px" size="3" multiple="multi ple">
<?php
$var=$_POST['proj_type'];
$firstcon=1;
$seccon=1;
if (!$var=="")
{
foreach( $var as $cat)
{
if ($firstcon== 1)
{
if ($cat="1")
{
$firstcon=2;
?>
<option selected value="1">Desig ning</option>
<?php
}
else
{
$firstcon=2;
?>
<option value="1">Desig ning</option>
<?php
}
}
if ($seccon== 1)
{
if ($cat="2")
{
$seccon=2;
?>
<option selected value="2">Progr amming</option>
<?php
}
else
{
$seccon=2;
?>
<option value="2">Progr amming</option>
<?php
}
}
}
}
else
{
?>
<option value="1">Desig ning</option>
<option value="2">Progr amming</option>
<?php
}?>
</select>
<?php
if(isset($_POST['S']))
{
$str="";
$var=$_POST['proj_type'];
foreach( $var as $cat)
{
if ($str=="")
{
$str=$cat;
}
else
{
$str=$str.",".$ cat;
}
}
}
echo $str;
?>
<select name="skill_typ e[]" style="width:12 0px" size="3" multiple="multi ple" >
<?php
if(isset($_POST['S']))
{
$skill=$_POST['proj_type'];
$str="";
foreach($skill as $cat)
{
if ($str=="")
{
$str=$cat;
}
else
{
$str=$str.",".$ cat;
}
$secondQry = "select * from skill_set where skill_type = '".$cat."'";
$sql = mysql_query($se condQry ) or die(mysql_error ());
while($row = mysql_fetch_ass oc($sql))
{
?>
<option selected value="<?php echo $row['skill_id'];?>"><?php echo $row['skill_name'];?></option>
<?php
}
}
}
?>
</select>
<input type="submit" name="S" value="Submit" id="Submit" >
</form>
</body>
</html>[/php]
Please enclose any code within the proper code tags. See the Posting Guidelines on how to do that.
MODERATOR
Comment