Re: Argh ! array help required :(

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

 



Hello Aaron,


* Try code like:

for ($i=0; $i<count($products); $i++) {
        $products[$i] = "'".escapeValue($products[$i])."'";
}
$list_products = implode(',', $products);
if (strlen($list_products)) {
        $prod_search = "in ($list_products)";
} else {
        $prod_search = '';
}



* HTML form control need to be like:

<select name="products[]" size="5" multiple>
        <option value="Product1">Product 1</option>
        <option value="Product2">Product 2</option>
        <option value="Product3">Product 3</option>
        <option value="Product4">Product 4</option>
        <option value="Product5">Product 5</option>
</select>


________________________

Best regards,
 Nenad Djordjevic                           mailto:nenad@diyomisoft.com
   
   Diyomi Soft
   http://www.diyomisoft.com/


Wednesday, February 5, 2003, 6:13:27 PM, you wrote:

AW> Hi All,
 
AW> Again.. a little off topic - sorry (again!).
 
AW> Have a form that allows me to select a bunch of product names from a
AW> drop down combo box.
 
AW> I'm trying to create code like "in ('Product name1','Product Name2) to
AW> be inserted into an SQL statement.
 
AW> I figured that since $products was ALREADY in an array format the code
AW> below would work.. but it doesn't:
 
AW> $prod_search = "in(";
AW> for ($i=0;$i<count($products);$i++) {                                
AW> $prod_search .= escapeValue($products[$i]);
AW>                         if ($i != (count($products) - 1)) {
AW>                                     $prod_search .= ",";
AW>                         }
AW>             }
 
AW> $prod_search .= ")";
 
AW> Can anyone see where I am going wrong?
 
AW> Thanks!
 
 
 
AW> Aaron 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


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

  Powered by Linux