Jump to content

tigomark

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tigomark's Achievements

Member

Member (2/5)

0

Reputation

  1. Ok I am trying to first get a list of stuff from an array created from a database. I am able to do that in funcion LeftSelect but what I would like to do is separate out values that are grabbed from another call and stored in $this->right_asset (vars 1,2,3,4) the values then would populate the RightSelect function LeftSelect(){ $assets = loadAllStuff($getConnection); $html = "<select name=\"target\" multiple=\"multiple\">\n"; if(is_array($assets)){ while(list ($key, $val) = each($assets)){ if (in_array($val->id, $this->asset_select_right)) { array_push($this->right_asset,($val->id, $val->stuff)); }else{ $html .= sprintf("<option value=\"%d\">%s</option>\n", $val->id, htmlspecialchars($val->stuff)); } } } $html .= "</select>\n"; return($html); }//assetSelect function RightSelect(){ $html .=sprintf(" <select name=\"selected\" size=\"10\">"); if(is_array($this->right_stuff)){ while(list($key, $val) = each($this->right_stuff)){ $html .= sprintf("<option value=\"%d\">%s</option>\n", $val->id, htmlspecialchars($val->stuff)); } } $html .=sprintf("</select>"); return($html); } I am trying if (in_array($val->id, $this->asset_select_right)) { array_push($this->right_asset,($val->id, $val->stuff)); which is currently not working in the left. If I take out the if I do get the all of the values so that is working. and the RightSelect is all fubar so I am kinda stuck.
  2. The problem was not in the code blocks but a count function that was not keeping proper track of the field count finished code if (isset($_REQUEST["datatypetarget"]) && is_array($_REQUEST["datatypetarget"]) && count($_REQUEST["datatypetarget"]) > 0) { $array = ($_REQUEST["datatypetarget"] ? $_REQUEST["datatypetarget"] : ""); $this->datatypetarget .= implode($array , ","); $this->formhandler = count($_REQUEST["datatypetarget"]); } else if (!is_array($_REQUEST["datatypetarget"])) { $array = explode("," , $_REQUEST["datatypetarget"]); $this->datatypetarget .= implode($array , ","); $this->formhandler = count($array); }
  3. I've tried adding in a n explode for the sorts no change if (isset($_REQUEST["datatypetarget"]) && is_array($_REQUEST["datatypetarget"]) && count($_REQUEST["datatypetarget"]) > 0) { $array = ($_REQUEST["datatypetarget"] ? $_REQUEST["datatypetarget"] : ""); $this->datatypetarget .= implode($array , ","); echo"First<br/>"; } else if (!is_array($_REQUEST["datatypetarget"])) { $array = explode("," , $_REQUEST["datatypetarget"]); echo"Second<br/>"; $this->datatypetarget .= implode($array , ","); }
  4. Thanks for the idea. That didn't make any difference.
  5. 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?
  6. I got it for ($i = 1; $i <= $this->formhandler; $i++){ $v = "reported_value".$i; $reporthtml .= sprintf("<td>%s</td>", $entry->$v); //var_dump($entry->reported_value[$i]); } However I now have another problem to get this to work and that is to create a header that limits itself by the same array if (is_array($this->dataTypes->data)) { reset($this->dataTypes->data); while (list($key, $val) = each ($this->dataTypes->data)) { if (($val->type != "N/A") && ($key <= $this->formhandler)) { $reporthtml .= sprintf("<td align=\"center\" nowrap=\"nowrap\">%s</td>", $val->name); } // $reporthtml .= sprintf("<td align=\"center\" nowrap=\"nowrap\">%s</td>", $val->name); } }
  7. I am having problems with my loop statement. Doing a var_dump shows that I am getting an integer of 1 and 2 (expected) for each row. But the variable is not holding it for some reason. for ($i = 1; $i <= $this->formhandler; $i++){ $reporthtml .= sprintf("<td>%s</td>", $entry->reported_value[$i]); var_dump($i); }
  8. I think that this might make more sense if I posted the whole code chunk (or maybe not since It's not making sense for me) if (is_array($this->dataTypes->data)) { reset($this->dataTypes->data); while (list($key, $val) = each ($this->dataTypes->data)) { if ($val->type != "N/A" && $val->type < 5) { $reporthtml .= sprintf("<td align=\"center\" nowrap=\"nowrap\">%s</td>", $val->name); }else if((count($val->type) - count($val->type != "N/A")) % 5){ $reporthtml .= sprintf("<td align=\"center\" nowrap=\"nowrap\"> </td>"); }
  9. Hello, I am trying to get the remainder of a field from the modulus of 5 to populate additional table headers. if((count($val->type) - count($val->type != "N/A")) % 5){ $reporthtml .= sprintf("<td align=\"center\" nowrap=\"nowrap\"> </td>"); } In the implimentation there are 8 fields 6 are N/A and 2 are good so I have 2 populated headers but I need to populate the other 3 with the empty space. However I could have 5 values so I am just trying to get the current amount and then fill the remaining with empty space. Any help would be great.
  10. I figured it out. I was still trying to parse those uneeded values. It works now. thanks for the help
  11. The output is as follows { ["action"]=> string( "showopen" ["operation"]=> string(0) "" ["datatypetarget"]=> array(2) { [0]=> string(1) "6" [1]=> string(1) "7" } ["assettarget"]=> string(1) "0" ["cfgtype"]=> string(2) "-1" ["startyear"]=> string(4) "2008" ["startmonth"]=> string(1) "2" ["startday"]=> string(2) "13" ["endyear"]=> string(4) "2008" ["endmonth"]=> string(1) "2" ["endday"]=> string(2) "14" ["goaction"]=> string( " Wait..." ["showunverified"]=> string(1) "0" } string(0) "" string(0) "" string(0) "" string(0) "" SQL: SELECT * from get_my_data_report(0, 0, 0, '2008-2-13'::timestamptz, '2008-2-14 23:59:59'::timestamptz, '' , -1, 0, 100)
  12. I should have tried to explain is that I am trying to parse it 2 different ways to see where I was getting a result and that the separating of the info at least gave me the ''. I know it's not correct but trying to handle the information as an array if (isset($_REQUEST["datatypetarget"]) && is_array($_REQUEST["datatypetarget"]) && count($_REQUEST["datatypetarget"]) > 0) { foreach ($_REQUEST["datatypetarget"] as $data_type) { if ($data_type != "") { $this->datatypetarget .= "," . $data_type ; }else{ $this->datatypetarget = ""; break; } } } else if (!is_array($_REQUEST["datatypetarget"])) { $this->datatypetarget = ($_REQUEST["datatypetarget"] ? $_REQUEST["datatypetarget"] : "''"); } var_dump($this->datatypetarget); Bombs out
  13. Hello, I am having a problem parsing the data from a multi-select field $html = "<select name=\"datatypetarget[]\" size=\"5\" multiple>\n"; The following is my parsing code to create a comma separated field I can put into a database call $this->assettarget = ($_REQUEST["assettarget"] ? $_REQUEST["assettarget"] : "NULL::INTEGER"); //data target handler $this->datatypetarget1 = ($_REQUEST["datatypetarget1"] ? $_REQUEST["datatypetarget1"] : "''"); $this->datatypetarget2 = ($_REQUEST["datatypetarget2"] ? $_REQUEST["datatypetarget2"] : ""); $this->datatypetarget3 = ($_REQUEST["datatypetarget3"] ? $_REQUEST["datatypetarget3"] : ""); $this->datatypetarget4 = ($_REQUEST["datatypetarget4"] ? $_REQUEST["datatypetarget4"] : ""); $this->datatypetarget5 = ($_REQUEST["datatypetarget5"] ? $_REQUEST["datatypetarget5"] : ""); var_dump($this->datatypetarget1); var_dump($this->datatypetarget2); var_dump($this->datatypetarget3); var_dump($this->datatypetarget4); var_dump($this->datatypetarget5); if (isset($_REQUEST["datatypetarget"]) && is_array($_REQUEST["datatypetarget"]) && count($_REQUEST["datatypetarget"]) > 0) { foreach ($_REQUEST["datatypetarget"] as $data_type) { if ($data_type != "") { $this->datatypetarget .= "," . $data_type ; }else{ $this->datatypetarget = ""; break; } } } else if (!is_array($_REQUEST["datatypetarget"])) { $this->datatypetarget = $_REQUEST["datatypetarget"]; $this->data->datatypetarget = $this->datatypetarget; } Currently from the var_dumps I get string(2) "''" string(0) "" string(0) "" string(0) "" string(0) "" so I am missing some values.
  14. I figured it out for ($j = 1; $j <= 11; $j++){ if(($entry->zoneColors[$j] == $entry->zoneColors[$j + 1]) && ($entry->zoneColors[$j] != 0)){ $entry->zoneColors[$j] = 12; } } I just needed to compare the array types in the view and then append to the unused 12th color in that instance. Thanks to all who looked at this
  15. mysql_connect(mysql,$username,$password); wouldn't that need to be mysql_connect([color=red][font=Verdana]$mysql[/font][/color],$username,$password); to match what ever your mysql value would be (unless this is your host name)?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.