after selection of multiple value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • permander kumar
    New Member
    • Mar 2008
    • 1

    #1

    after selection of multiple value

    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
    Last edited by ronverdonk; Mar 11 '08, 10:28 AM. Reason: code within tags
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    Please visit this page:

    http://www.thescripts. com/forum/faq.php?faq=how _to_ask_a_quest ion


    Make proper modifications to your post (ie add CODE tags)

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      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

      Comment

      Working...