Hello,
I have created a select product using a different way like frst we select product from dropdown and click on next button on next page the dropdown have to show the company names i.e only that companies which belongs to the selected product but i am bit confused how it will work i tried to use v_id like company id but its not working can anyone help me out.
Database structure
CREATE TABLE IF NOT EXISTS `products` (
`prod_id` int(11) NOT NULL AUTO_INCREMENT,
`product_name` varchar(255) NOT NULL,
`product_price` int(20) NOT NULL,
`prod_details` text NOT NULL,
`v_id` int(11) NOT NULL,
`v_name` varchar(45) NOT NULL,
PRIMARY KEY (`prod_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ;
--
-- Dumping data for table `products`
--
INSERT INTO `products` (`prod_id`, `product_name`, `product_price`, `prod_details`, `v_id`, `v_name`) VALUES
(6, 'Samsung Elite Book', 1200, 'Samsung Ci3 Laptop with 8GM ram 2 years official international warranty ', 3, 'Samsung'),
(8, 'Samsung Galaxy S5', 400, 'This is anew just launched product having great features then ever buy now and get your self with a valuable product', 3, 'Samsung'),
(9, 'Samsung Galaxy S4', 350, 'Samsung Galaxy S4 this product is one of the most using cellphone in the market', 3, 'Samsung'),
(10, 'LED', 0, 'wewewewe', 3, 'Samsung'),
(11, 'TV ', 500, 'ajksdjadkaskdbkasdbkasdklkasdkbkasdksbadklbaskdbjksad', 6, 'Azeem'),
(12, 'Iphone', 500, 'gasdhasgdghasdgha', 7, 'Noman'),
(13, 'Air Condintion', 600, 'This is new product in market now', 3, 'Samsung');
First page when you try to select the product
<form method="POST" action="select_vendor.php?id=<?php echo $product_id; ?>">
<div id="order">
<?php
$query = "SELECT * FROM products";
$query_confirm = mysqli_query($connection, $query);
echo "<select name='product'>";
echo "<option>" . "Select Product" . "</option>";
while ($row_product = mysqli_fetch_assoc($query_confirm)) {
$product_id = $row_product["v_id"];
$product = $row_product["v_name"];
echo "<option>" . $product . "</option>";
}
echo "</select>";
?>
<input type="submit" value="NEXT >" class="btn-green" name="submit" />
</div>
</form>
Now this is the second page where you wil be seleting the company of your choice
<?php
if (isset($_POST['submit'])) {
$product_info = $_POST['product'];
}
$id = $_GET['id'];
echo "Your Select Product" . " " .$product_info;
echo "<br />";
echo "<a href='index.php'>Cancel</a>";
?>
<div id="order">
<?php
$query = "SELECT * FROM products WHERE v_id={$id} LIMIT 1";
$query_confirm = mysqli_query($connection, $query);
echo "<select name='product'>";
echo "<option>" . "Select Vendor" . "</option>";
while ($row_product = mysqli_fetch_assoc($query_confirm)) {
$product_vendor = $row_product["v_name"];
echo "<option>" . $product_vendor . "</option>";
}
echo "</select>";
?>
<input type="submit" value="VIEW PRODUCT >" class="btn-green" />
</div>
I am also not getting the link as well on the action if I had get the link i beleive it would be easy enough to to do so
Thank You in advance