Hello,
I am having some problems using implode in my script. I am trying to take the array of a multi select and create a comma separated list for a query. When the form posts it works as expected but when I go to sort my different columns it tries to cut down the comma separated lest again until it reaches just one instance.
if (isset($_REQUEST["datatypetarget"]) && is_array($_REQUEST["datatypetarget"]) && count($_REQUEST["datatypetarget"]) > 0) {
$array = ($_REQUEST["datatypetarget"] ? $_REQUEST["datatypetarget"] : "");
$this->datatypetarget .= implode($array , ",");
} else if (!is_array($_REQUEST["datatypetarget"])) {
$this->datatypetarget = ($_REQUEST["datatypetarget"] ? $_REQUEST["datatypetarget"] : "");
}
The link code
$myopts = sprintf("startyear=%d&startmonth=%d&startday=%d&endyear=%d&endmonth=%d&endday=%d&showall=%d&datatypetarget=%s",
$this->startdate->year, $this->startdate->month, $this->startdate->day,
$this->enddate->year, $this->enddate->month, $this->enddate->day, $this->showall, $this->datatypetarget);
When the form is posted I have an array of up to 5 values
1,2,3,4,5
However with each sort the implode is causing it to diminish
1,2,3,4
1,2,3
1,2
1
1
1
1 and so on.
Will I need to add another type of checking to get this to work corectly?