Jump to content

dropdown selection module configuration


Recommended Posts

I am displaying a table using smarty in module configuration page, which is filled with order data per customer. The table takes data from the database dynamically, but the customer id is hardcoded in the query. I need to have the customer id selection done in a dropdown menu. How do I do that with smarty?

the php code: 

 $zar1sql = 'SELECT
od.product_quantity,
o.id_order
FROM
	ps_product_lang as pl
	 JOIN `ps_product`
	ON `ps_product`.id_product = pl.id_product
	Join `ps_order_detail` as od
	ON `ps_product`.id_product = od.product_id
	JOIN `ps_orders` as o
	on od.id_order = o.id_order
	Join ps_customer as c
	on o.id_customer = c.id_customer
	where c.id_customer = 2 AND pl.id_product = 20';
        $something4 = mysqli_query($con, $zar1sql);
        $result4 = mysqli_fetch_all($something4, MYSQLI_BOTH);
        $zar1 = [];
        foreach ($result4 as $row) {
            $zar1[] = $row[0];
        }
        $this->smarty->assign('zar1', $zar1);


        return $this->display(__FILE__, 'views/templates/admin/afinalmodule.tpl');

The customer id is hardcoded, so it displays results only for customer id 2 as seen here: where c.id_customer = 2 AND pl.id_product = 20';

How is the data set in the query based on the choice in the dropdown?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...