Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    Posts
    1

    Unanswered: Dynamic Drop Down List

    I have multiple products and in one form I have two dropdown list with the products in each. What I want to do is have the visitor choose a product in each drop down and then pass those to another page where I can display each products data.

    Currently I am passing this form to another page:

    <form method="post" action="compare_con.php">
    <table width="50%" border="0" align="center" cellpadding="5" cellspacing="5">
    <tr>
    <td width="43%"> <div align="center" class="body"><strong><font color="#CC0000">
    <select name="product_01">
    <option value="" selected <?php if (!(strcmp("", $row_db['product_name']))) {echo "SELECTED";} ?>>Choose
    a Product</option>
    <?php
    do {
    ?>
    <option value="<?php echo $row_db['product_name']?>"<?php if (!(strcmp($row_db['id'], $row_db['product_name']))) {echo "SELECTED";} ?>><?php echo $row_db['product_name']?></option>
    <?php
    } while ($row_db = mysql_fetch_assoc($db));
    $rows = mysql_num_rows($db);
    if($rows > 0) {
    mysql_data_seek($db, 0);
    $row_db = mysql_fetch_assoc($db);
    }
    ?>
    </select>
    </font></strong> </div></td>
    <td width="16%"><div align="center" class="body">VS.</div></td>
    <td width="41%"> <div align="center"><strong><font color="#CC0000">
    <select name="product_02">
    <option value="" selected <?php if (!(strcmp("", $row_db['product_name']))) {echo "SELECTED";} ?>>Choose
    a Product</option>
    <?php
    do {
    ?>
    <option value="<?php echo $row_db['product_name']?>"<?php if (!(strcmp($row_db['product_name'], $row_db['id']))) {echo "SELECTED";} ?>><?php echo $row_db['product_name']?></option>
    <?php
    } while ($row_db = mysql_fetch_assoc($db));
    $rows = mysql_num_rows($db);
    if($rows > 0) {
    mysql_data_seek($db, 0);
    $row_db = mysql_fetch_assoc($db);
    }
    ?>
    </select>
    </font></strong> </div></td>
    </tr>
    <tr>
    <td colspan="3"><div align="center">
    <input type="submit" name="Submit" value="Submit">
    </div></td>
    </tr>
    </table></form>

    I know how to display the name of the products on the next page by writing this:

    <?php echo $_POST['product_01'];?> vs <?php echo $_POST['product_02'];?>

    but underneath that I want to display the price of each, the ingredients of each...so forth and so on. That is where I am at and I would appreciate any help that is available. Thanks so much!

  2. #2
    Join Date
    Aug 2003
    Posts
    32
    Could you select that information from the database using the product name that was posted or have I missunderstood what you mean?

    PHP Code:
      $sql "select * from my_products where id = \"{$_POST["product_01"]}\"";
      
    $result $mysql_query($sql);
      
    $row mysql_fetch_array($result);
      echo 
    "Price: {$row["price"]}<br>Description: {$row["description"]}<br>"// etc. 

Posting Permissions

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