dynamic select list question

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default dynamic select list question

    Greetings, I have posted the working code. My question is how do I capture what
    was selected from the lists? I am a total newbie to this stuff and really have
    looked for an answer for several days :-)

    Thanks in advance!

    <!-- Require pre-defined connection -->

    <?php require_once('Connections/ssit_mysql.php'); ?>
    <?php
    // Connect/select the database and give error if cannot connect. Choose
    columns. Get the row count
    mysql_select_db($database_ssit_mysql, $ssit_mysql);
    $query_Process = "SELECT * FROM process_node";
    $Process = mysql_query($query_Process, $ssit_mysql) or die(mysql_error());
    $row_Process = mysql_fetch_assoc($Process);
    $totalRows_Process = mysql_num_rows($Process);

    mysql_select_db($database_ssit_mysql, $ssit_mysql);
    $query_foundry = "SELECT * FROM foundry";
    $foundry = mysql_query($query_foundry, $ssit_mysql) or die(mysql_error());
    $row_foundry = mysql_fetch_assoc($foundry);
    $totalRows_foundry = mysql_num_rows($foundry);

    mysql_select_db($database_ssit_mysql, $ssit_mysql);
    $query_category = "SELECT type FROM category";
    $category = mysql_query($query_category, $ssit_mysql) or die(mysql_error());
    $row_category = mysql_fetch_assoc($category);
    $totalRows_category = mysql_num_rows($category);

    mysql_select_db($database_ssit_mysql, $ssit_mysql);
    $query_technology = "SELECT * FROM technology";
    $technology = mysql_query($query_technology, $ssit_mysql) or
    die(mysql_error());
    $row_technology = mysql_fetch_assoc($technology);
    $totalRows_technology = mysql_num_rows($technology);
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Library Select</title>
    </head>

    <body>
    <table width="200" border="2" bordercolor="0b3aa3">
    <tr>
    <th scope="col">Foundry</th>
    <th scope="col">Technology</th>
    <th scope="col">Category</th>
    <th scope="col">Process Node</th>
    </tr>
    <tr>
    <td><div align="center">

    <!-- removed {echo "SELECTED";} to not have pre-selected items in the list
    -->
    <select name="foundry" size="6" multiple>
    <?php
    do {

    ?>
    <option value="<?php echo $row_foundry['foundry']?>"<?php if
    (!(strcmp($row_foundry['foundry'], $row_foundry['foundry']))) ?>><?php echo
    $row_foundry['foundry']?></option>
    <?php
    } while ($row_foundry = mysql_fetch_assoc($foundry));
    $rows = mysql_num_rows($foundry);
    if($rows > 0) {
    mysql_data_seek($foundry, 0);
    $row_foundry = mysql_fetch_assoc($foundry);
    }
    ?>
    </select>
    </div></td>
    <td>
    <div align="center">
    <select name="x" size="6" multiple>
    <?php
    do {
    ?> <!-- select the 'select' statement to add a behavior -->
    <option value="<?php echo $row_technology['tech']?>"><?php echo
    $row_technology['tech']?></option>
    <?php
    } while ($row_technology = mysql_fetch_assoc($technology));
    $rows = mysql_num_rows($technology);
    if($rows > 0) {
    mysql_data_seek($technology, 0);
    $row_technology = mysql_fetch_assoc($technology);

    }
    ?>
    </select>
    </div></td>
    <td>
    <div align="center">
    <select name="Category" size="6" multiple id="Category">
    <?php
    do {
    ?>
    <option value="<?php echo $row_category['type']?>"<?php if
    (!(strcmp($row_category['type'], $row_category['type']))) ?>><?php echo
    $row_category['type']?></option>
    <?php
    } while ($row_category = mysql_fetch_assoc($category));
    $rows = mysql_num_rows($category);
    if($rows > 0) {
    mysql_data_seek($category, 0);
    $row_category = mysql_fetch_assoc($category);
    }
    ?>
    </select>
    </div></td>
    <td>
    <div align="center">
    <select name="Process Node" size="6" multiple id="Process Node">

    <?php

    do {
    ?>


    <option value="<?php echo $row_Process['process']?>"<?php if
    (!(strcmp($row_Process['process'], $row_Process['process']))) ?>><?php echo
    $row_Process['process']?></option>
    <?php
    } while ($row_Process = mysql_fetch_assoc($Process));
    $rows = mysql_num_rows($Process);
    if($rows > 0) {
    mysql_data_seek($Process, 0);
    $row_Process = mysql_fetch_assoc($Process);
    }



    ?>

    </select>
    </div></td>
    </tr>
    </table>



    </body>
    </html>

    <?php

    // This will free up the memory from the mysql calls

    mysql_free_result($Process);

    mysql_free_result($foundry);

    mysql_free_result($category);

    mysql_free_result($technology);
    ?>

    Guitar53 Guest

  2. Similar Questions and Discussions

    1. Select List Help
      How can I create a select menu input that looks at what the user enters and suggests the approiate matching item that I query from my database? In...
    2. Select a list of items into an aliased field when doinga select
      OK I know this is going to sound weird, but I'm wondering if this is possible. I have a task table. (tblTask) These tasks can be assigned to...
    3. Dynamic List Question
      I have a dynamic list that users can select multiple choices and I want on the edit page to have all those choices pre-selected. The values are...
    4. SELECT DISTINCT + ORDER BY gives ERROR 145: ORDER BY items must appear in the select list if SELECT DISTINCT is specified.
      Following is my stored procedure. If I take the DISTINCT out then everything works fine. BUT I need the distinct because it returns duplicate...
    5. SELECT DISTINCT + ORDER BY gives ERROR 145: ORDER BY items mustappear in the select list if SELECT DISTINCT is specified.
      Dan, You should be able to do this: SELECT Id, FaxID, ReceivedTime, Pages FROM ( SELECT DISTINCT .Id AS Id,
  3. #2

    Default Re: dynamic select list question


    "Guitar53" <webforumsuser@macromedia.com> wrote in message
    news:d44b4v$shf$1@forums.macromedia.com...
    > Greetings, I have posted the working code. My question is how do I capture
    > what
    > was selected from the lists? I am a total newbie to this stuff and really
    > have
    > looked for an answer for several days :-)
    <snip>

    Your <select> elements should be enclosed in a <form> tag.
    The form would have an action= and method=. Processing this
    form would allow you to capture the select values.

    Example: if you choose method="post" the select values would
    be available in the $_POST[] array.

    HTH

    -Rb

    -Rb Guest

  4. #3

    Default Re: dynamic select list question

    Thanks alot for the help Rb!
    I think I almost have this part working now.
    Guitar53 Guest

  5. #4

    Default Re: dynamic select list question

    Well I was wrong, I am not close to getting this to work :}
    I have added the form tags etc.. The menu come up fine and I can 'select' an
    item ok but that's all...
    I made a smaller example script ( test.php ) but I havn't been able to get
    what is selected in the menu to show up in test2.php. Any suggestions on what I
    need to do will be greatly appreciated !



    test.php:
    <?php require_once('Connections/hyperion.php'); ?>
    <?php
    mysql_select_db($database_hyperion, $hyperion);
    $query_Recordset1 = "SELECT * FROM lib_names";
    $Recordset1 = mysql_query($query_Recordset1, $hyperion) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>

    <body>
    <form action="test2.php" method="post" >
    <select>
    <?php
    do {
    ?>
    <option value="<?php echo $row_Recordset1['library']?>"><?php echo
    $row_Recordset1['library']?></option>
    <?php
    } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
    $rows = mysql_num_rows($Recordset1);
    if($rows > 0) {
    mysql_data_seek($Recordset1, 0);
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    }
    ?>
    </select>

    <input type="submit" name="Submit" value="Submit">
    </form>
    <?php echo $row_Recordset1['library']; ?>
    </body>
    </html>
    <?php
    mysql_free_result($Recordset1);
    ?>

    test2.php

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>

    <body>
    <?php echo $_POST['recordset1[library]'];?>



    </body>
    </html>

    Guitar53 Guest

  6. #5

    Default Re: dynamic select list question

    Ok I got it working! I needed to add to the shorter example code
    <select name="library[]" >
    then use
    <?php echo $_POST['library'] [0]; to get the correct output.

    Thanks again Rb for pointing me in the right direction!

    Guitar53 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139