By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,190 Members | 1,503 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,190 IT Pros & Developers. It's quick & easy.

after selection of multiple value

P: 1
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("connect.php");
?>
<html><body>
<form name="check" method="post" >

<select name="proj_type[]" style="width: 120px" size="3" multiple="multiple">
<?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">Designing</option>
<?php
}
else
{
$firstcon=2;
?>
<option value="1">Designing</option>
<?php
}
}
if ($seccon== 1)
{
if ($cat="2")
{
$seccon=2;
?>
<option selected value="2">Programming</option>
<?php
}
else
{
$seccon=2;
?>
<option value="2">Programming</option>
<?php
}
}
}
}
else
{
?>
<option value="1">Designing</option>
<option value="2">Programming</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_type[]" style="width:120px" size="3" multiple="multiple" >
<?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($secondQry ) or die(mysql_error());
while($row = mysql_fetch_assoc($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
Mar 11 '08 #1
Share this Question
Share on Google+
2 Replies


dlite922
Expert 100+
P: 1,584
Please visit this page:

http://www.thescripts.com/forum/faq.php?faq=how_to_ask_a_question


Make proper modifications to your post (ie add CODE tags)
Mar 11 '08 #2

ronverdonk
Expert 2.5K+
P: 4,258
Although the code has been embedded (by me) within code tags, it is still unstructured and thus (almost) unreadable and will not encourage members to have a closer look. Please restate your problem in some more detail. See the Posting Guidelines on forum behaviour.
Give as much detail as possible When you post a question or problem, express the situation clearly and concisely and include all relevant information, code used, data used, result expected, result achieved and any error codes or messages that you get as a result.

Use Clear English to write your question in if possible, try to avoid using abbreviations

Do not use leet speak or text speak, they are not Clear English
moderator
Mar 11 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.