- I have one single inquiry form (php page) that contain a drop-down SELECT containing all products.
<select class="form-control" name="model_name" required="" id="modals">
<option> Choose Model *</option>
<?php
$fetch = $, com_in->prepare("SELECT * FROM main_product_tbl WHERE type='1'");
$fetch->execute();
$c = 1;
foreach ($fetch->fetchAll(PDO::FETCH_ASSOC) as $key)
{
echo '
<option value="' . $key['product_id'] . '">' . $key['model_name'] . '</option> ';
$c++;
}
?>
</select>
- All these products have their separate/individual web pages.
Each product page has Inquiry Button, that loads the Inquiry Form (a php page)
there user has to select particular product from the drop-down SELECT.
I want that if user press the inquiry button (from any product page), it should load the Inquiry page and the respective product item should be automatically selected in the drop-down.
Kindly help.
2
Answers
Pass product id or name through url and fetch value from db on inquiry page
http://www.site.com/enquiry.php?=productid
On enquiry page
fetch details from database useing id or product name
As first you must set a variable/cookie with the current product. In this example, it will be
Then, add this code inside the
<option>
tag