Skip to main content
Topic: view page of multiple selected value and labels (Read 2930 times) previous topic - next topic

view page of multiple selected value and labels

Dear friends,
I have stucked in one issue and cannot figure it out.
I have two tables as
companies and sites

companies : id, name, etc.
Sites: id, sitename, referencecompany(foreignkey), etc.


one company may have multple sites.
I use multi selection in add page(company) as value = id and label = sitename

İssue is  multi selected IDs ar written in sql as an example " 2,5,7"
view page shows only IDs as text view. as "2,5,7"
when I choose mater detail, I can see related view as modal (label of the value) but only one site not all the chosen seperatedly.

is the any way to correct the issue or is it a some bug?




Re: view page of multiple selected value and labels

Reply #1
@gokand‍ this is not a bug, this was how to was built. In the future, there might be an update to resolve it, but now, you will have to write your PHP code to handle it for you.

Re: view page of multiple selected value and labels

Reply #2
@gokand‍ this is not a bug, this was how to was built. In the future, there might be an update to resolve it, but now, you will have to write your PHP code to handle it for you.
Thank you for your support. Is ıt possible get the support of coding from you? maybe via patreon


Re: view page of multiple selected value and labels

Reply #4
<?php
//single row:
$company_id=$cid;
$cmtcc = new CompanyController;
$db = $cmtcc->GetModel();
//execute SQL statement and return a single row
$params = array($company_id);
 $array  = $db->rawQuery("SELECT * FROM company WHERE id = ?", $params);
 $company=$array['0'];
?>
 <br <?php echo $company['company']; ?>
<br> <?php echo (ucwords($company['vat'])); ?>
//etc....
<?
//many rows
// one way  in my case $products_in_cart is an array with a product_ids and quantitys

$cmtc = new ProductController;
$db = $cmtc->GetModel();
$exeq = (array_keys($products_in_cart));
$counter = 0;
               for($i=0; $i<count($exeq); $i++){
             $pid = $exeq[$i];
             $pid = array($pid);
             $pids = $db->rawQuery("SELECT * FROM product WHERE id = ?", $pid);
             $product = $pids['0'];
             $counter++;
?>
 <br <?php echo $product['name'; ?>
 <br <?php echo $product['id'; ?>
<?
}

// the above code is simple but could crash, so it is better to call the db array first then the loop as:
$params = array($products_in_cart);
$arr = $db->rawQuery("SELECT * FROM product WHERE id IN (?)", $params );

see also: https://phprad.com/forum/index.php?topic=834.0
especially wilvin links and video