Create dropdown menu retrieves all items in a database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • reigns7703
    New Member
    • Dec 2012
    • 4

    Create dropdown menu retrieves all items in a database

    Code:
    $query_Test = "SELECT * FROM Products WHERE Product_Type='$Product_Type' ORDER BY Product_Title ASC";
    $query_limit_Test = sprintf("%s LIMIT %d, %d", $query_Test, $startRow_Test, $maxRows_Test);
    $Test = mysql_query($query_limit_Test, $WPhoto) or die(mysql_error());
    $row_Test = mysql_fetch_assoc($Test);
    
    
                <form id="form1" name="form1" method="get" action="products.php">
      <p>
        <label>Narrow Your Search:
          <select name="Product_Type" method="post">
          <option value="Product_Type" selected="selected">All</option>
            <option value="Chips">Chips</option>
            <option value="Dips, Marinades">Dips, Marinades</option>
            <option value="Rubs">Rubs</option>
          </select>
        </label>
        <label>
          <input type="submit" name="button" id="button" value="Submit" />
        </label>
      </p>
    </form>
  • reigns7703
    New Member
    • Dec 2012
    • 4

    #2
    And then I have....

    Code:
                <?php do { ?>
                <p><img src = "images/<?php echo $row_Test['Product_Image_Small']; ?>" align="left"/><br />
                   <a href="productdetails.php?recordID=<?php echo $row_Test['Product_ID']; ?>" >
                   <?php echo $row_Test['Product_Title']; ?></a><br />
                   <?php echo $row_Test['Product_Type']; ?><br />
                   <?php echo $row_Test['Product_Description']; ?><br />
                   <?php } while ($row_Test = mysql_fetch_assoc($Test)); ?>
                </p>
             </div>

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      I don't understand what your question is. Just loop through your result set and write out the options to the document.

      Comment

      • reigns7703
        New Member
        • Dec 2012
        • 4

        #4
        Hi Rabbit,
        Please forgive my ignorance, but how do I go about doing that?

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          The same way you do it in post #2. Except instead of putting it between a p element, put it between an option element.

          Comment

          Working...