[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
On Sat, 2011-04-23 at 21:09 +0100, Gordon Henderson wrote: > On Sat, 23 Apr 2011, Kevin Lucas wrote: > > > Hi all hope you are enjoying this Easter sunshine break? > > No rest for the wicked... > (and we had thunder here earlier!) > > > //but I get a ,' left at the end so the query wont run > > > > So is there an easier way of collecting the string together with commas > > between and delimited by ' ' ? > > If all else fails, use brute force: > Finall messy but it works this is the output loop round count of checkboxes and add comma ('70765','XM411','BP10891',') ('70765','XM411','BP10891') raw output of query to see whats fetched Array ( [code] => 70765 [product] => Schwepps Tonic [product2] => Water 1ltr ) Array ( [code] => bp10891 [product] => milk choc digestive [product2] => 300g ) Array ( [code] => XM411 [product] => Mistletoe [product2] => Kisses ) Product Product2 Code Schwepps 1ltr 70765 milk choc digestive 300g bp10891 Mistletoe Kisses XM411 I used brute force as you said $i =0 if(isset($_POST['box'])) { $check_val .="('"; //start the brackets and a ' to start for ($i=0; $i<count($_POST['box']);$i++) { $check_val .= $_POST['box'][$i]; $check_val .="','"; //add a ',' in the middle of each }$check_val .=")"; // this sticks a ) at the end } echo "<br>"; echo "$check_val <br>";// see what we have $code1 = substr($check_val,0,-3);// oops we have to remove a ) and a ' and a , $code1 .=")"; // then I have to add back a ) to complete the set echo "$code1 <br>"; > Gordon > I'm sure real programming isn't as messy as this but I will continue testing and tidying up who knows it might reduce to that elusive "one liner" Thanks for the inspiration. -- Regards Kevin Lucas Minions Post Master(Sub) Eleven Years in the Making! www.minionsbandb.co.uk www.tearooms.minionsbandb.co.uk FaceBook Minions_shop Po House, Minions, Liskeard Cornwall PL14 5LE 01579363386 -- The Mailing List for the Devon & Cornwall LUG http://mailman.dclug.org.uk/listinfo/list FAQ: http://www.dcglug.org.uk/listfaq