Greetings all,

I am currently in the process of setting up a e-commerce suite on a client
website but as I am a PHP MySQL newbie, I have come accross a few problems. I have a product page which has static information on it. I have a form with
a dropdown box. I want this dropdown box to show data from three different columns in a MySQL database table. These would be, Colour, Size and Price.
I have the database setup and running with Apache, PHP and MySQL all
installed, configured and fully operational.

I am using Dreamweaver MX 2004 and have already setup the dropdown on the
page using the DW insert List/Menu feature. I have been able to select what
dynamic data I would like to show by use of a recordset I have already setup
with all the relevant columns.

The first problem I have is the DW insert list/menu feature only allows me to show one column of data. I want to show all three one after the other in
the same dropdown box. I am sure this is possible because I have done this
using SQL in MS Access. I am unsure how this is done in PHP MySQL.

The second problem I have is that I would like the selected data from the
dropdown to be transported to the next page which will be the Review Cart
page. I have read on forums that the use of variables would do this for me
but am unsure as to how I would implement them into dropdown on the product page.

The third problem I have is I do not quite understand how the dropdown would only show the Colour, Size and Price options for the product of that product page. I have a dynamic dropdown tutorial which states that a parents and child lists would be needed, but seeing as I am only having one dropdown box, I think the child list would not be necessary.

Would I need to put a parentID column in the database table and give an ID for each set of options? for example, Bracelet would have Silver, Gold and Silver Plate.

Would I need to put an ID of 1 for each of these and then go on to put 2 for the next set of options for another product and 3 for the next and so on?

Any help would be much appreciated.

Thank-you all,

Regards,

Rue

    If I understand you correctly, you want a multi-column display in your dropdown as per Access combo-box. EG

    Gold 24cm £20
    Gold 36cm £30
    Silver 24cm £10
    silver 36cm £15

    Yes?

    In that case you just need to do this:

    <?php
    $sql = "SELECT * FROM products WHERE type= $_POST['type']";
    
    // type being eg bracelet selected on previous page and posted to this page
    
    $result = $mysql_query($sql);
    
    echo '<select>';
    while $row = mysql_fetch_array($result) {
         echo '<option value=' . $row['prodid'] . '>' . $row['colour'] . ' ' . $row['size'] . ' ' .$row['price'] . '</option>';
        }
    echo '</select>';
    
    ?>
    

    Biggest problem will be list alignment. I have just concatenated each field with a space between to give you the idea. And I have not bothered too much about the query string so you may have to.

      The dropdown needs to be on the product page and wouldnt get data from a previous page.

      This is the code I have so far:

      <select name="select">
                                  <option value="0">Please Select One</option>
                                  <?php
      do {  
      ?> <option value="<?php echo $row_Recordset1['Title']?>"><?php echo $row_Recordset1['Title']?></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>

      The problem is that DW only lets me show one column. I need to show three in the one dropdown.
      The customer would then select the relevant option for that specific product and the data would be posted to the next page(the review cart page).

        Well, I don't know of any way to show multiple columns in an html dropdown. That is why I concatenated them into 1 string in my example. All you need to return, infact all you will return, from the user's selcetion is the option value. Post that to the next script, which can extract the relevent data for itself using the posted index value.

          Write a Reply...