Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

So basically what I want to do is get a result from a row in my database table based on the selection of my dropdown value.

I am making a product description page where all my product information lies within a mysql database.

What I did is I made an array from a row in my database and put that in a foreach loop to put that array in my dropdown.

include_once('php/connect_to_db.php');

        $dimensions = array(); //Array for product Dimensions
        $sizes = array(); //Array for product Dimensions
        $prices = array(); //Array for product Dimensions

        $selected_desc = $_GET['desc']; // Get Product Link

        $result = mysqli_query($con, "SELECT * FROM beds WHERE `Product Name` = '$selected_desc' ");

        while($row = mysqli_fetch_array($result))
            {

                $dimensions = explode(",", $row['Dimensions (L x H x W)']);
                $sizes = explode(",", $row['Available Sizes']);

                $product_select = array_combine($dimensions, $sizes);

                if (count($sizes) != 0) {

                    echo "<font class=\"finish\">Please select size:</font>";
                    echo "<select id=\"product_dropdown\" onChange=\"\">";

                    foreach($sizes as $descriptive) {

                    ?>                          
                        <option value="<?php echo $descriptive; ?>"><?php echo $descriptive; ?></option>
                    <?php

                    }

                    echo "</select>";

                }

My problem now comes in when I want to display 'size', 'dimension' & 'price' in a table. I want to display these values of the item which is selected in the dropdown box.

                        <td width="25%">

                            <?php echo $sizes[1]; ?>

                        </td>

                        <td width="50%">
                            <?php echo $dimensions[1]; ?>

                        </td>

                        <td width="25%">

                            <span class="price"> <?php echo $prices[1]; ?> </span>

                        </td>

I figure I should use javascript of JQuery to display the data in the table, but I have not the foggiest idea on how to do this. Any advice would be greatly appreciated. Thanks.

share|improve this question
1  
Danger: You are vulnerable to SQL injection attacks that you need to defend yourself from. –  Quentin Dec 9 '13 at 15:29
 
I will check that out, thanks. –  user2587418 Dec 9 '13 at 15:30
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.