D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] php mysql help

 

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:

  $x = "" ;
  foreach ($_POST ['box'] as $y)
    if ($x == "")
      $x = $y ;
    else
      $x .= ",'" . $y . "'" ;

  $x = "(" . $x . ")" ;

etc. (untested, use at your own risk, etc. and it's probably advisable to make sure _POST ['box'] isn't empty or the foreach might whinge).

And I hope you're validating the POST data before sending to to mysql though... (little bobby tables and all that)

Gordon

--
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq