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.