Help with select box - multiple...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,
 
Sorry to be a pain on this one as it is sorta off topic.. but any help
would be awesome.
 
I'm creating a report for Product Popularity in which the Admin is
present with a form and they have the ability to select A product or
multiple products from a drop down combo box.
 
The form is submitted to itself.. and all works.. meaning I can select
multiple products from the drop down box and the results displayed fine.
However, I want to SHOW to the user (in the drop down box) which
products were selected. Things work fine if I am selecting on product -
meaning it show the product name being sleected.. however, if multiple
products are selected it doesn't show any as being selected.
 
The select box code is below as is the script to iterate through the
products array.
 
Thanks all.
 
 
*** product select box ***
 
<select name="products[]" class="selectcontent" size="3" multiple>
 

<option value="" class="selectcontent">Product</option>
 
<?php
 
 
$productQuery = db_query("SELECT name, SUM(quantity) as mostSold FROM
CartTable WHERE submitted=1 GROUP BY name ORDER BY mostSold DESC");
 
while ($productResult = db_fetch($productQuery)) {
 
?>
 

 

 
<option value="<?php echo $productResult['name']; ?>" <?php if
($productResult['name'] == $str_products) echo "selected"; ?>
class="selectcontent"><?php echo $productResult['name']; ?></option>
 
<?php
                
                }
 
?>
 

</select>
 
 
 
*** array iteration code **
 
if ($products) {
 
                if (is_array($products)) {
 
                                $str_products = implode(",",$products);
                                                
                } 
 
                else {
 
                                $str_products = $products;
 
                }
 
                echo $str_products;
 
}
 
 
 
 
Aaron

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux