tigomark Posted January 28, 2008 Share Posted January 28, 2008 Hello, I'm having with one of my arrays having a zero value and I'm not sure why This is the array $this->color[] = "#ff0000"; $this->color[] = "#0000ff"; $this->color[] = "#00ff00"; $this->color[] = "#FF6600"; $this->color[] = "#CC00CC"; $this->color[] = "#EDDC34"; $this->color[] = "#FFCC00"; $this->color[] = "#CC66CC"; $this->color[] = "#CC9999"; $this->color[] = "#CDDF60"; $this->color[] = "#44e2f1"; $this->color[] = "#33FFCC"; for ($i=0; $i<=11; $i++){ $this->zoneColors = $this->color[$i]; //var_dump($this->zoneColors); } $this->zoneColors = "#ffffff"; Here is the row values from the query $this->zone1_id = $row['zone1_id']; $this->zone2_id = $row['zone2_id']; $this->zone3_id = $row['zone3_id']; $this->zone4_id = $row['zone4_id']; $this->zone5_id = $row['zone5_id']; $this->zone6_id = $row['zone6_id']; $this->zone7_id = $row['zone7_id']; $this->zone8_id = $row['zone8_id']; $this->zone9_id = $row['zone9_id']; $this->zone10_id = $row['zone10_id']; $this->zone11_id = $row['zone11_id']; Here is the view population $reporthtml .= sprintf("<td><span style=\"width:100%%; white-space: nowrap; \">%s</span></td> <td><span style=\"width:100%%; white-space: nowrap; \">%s</span></td> <td><span style=\"width:100%%; white-space: nowrap; \">%s</span></td> <td><span style=\"width:100%%; white-space: nowrap; \">%s</span></td> <td><span style=\"width:100%%; white-space: nowrap; \">%s</span></td> <td bgcolor=\"%s\" title=\"%s - %s\" > </td><td bgcolor=\"%s\" title=\"%s - %s\"></td><td bgcolor=\"%s\" title=\"%s - %s\"></td><td bgcolor=\"%s\" title=\"%s - %s\"> </td><td bgcolor=\"%s\" title=\"%s - %s\"></td><td bgcolor=\"%s\" title=\"%s - %s\"></td><td bgcolor=\"%s\" title=\"%s - %s\"></td> <td bgcolor=\"%s\" title=\"%s - %s\"></td><td bgcolor=\"%s\" title=\"%s - %s\"></td><td bgcolor=\"%s\" title=\"%s - %s\"></td> <td bgcolor=\"%s\" title=\"%s - %s\"></td></tr>\n", $entry->inspType, $entry->assetName, $entry->inspID, $entry->operator, $entry->date, $this->zoneColors[$entry->zone1_id], $entry->zonename1, $entry->timestamp1, $this->zoneColors[$entry->zone2_id], $entry->zonename2, $entry->timestamp2, $this->zoneColors[$entry->zone3_id], $entry->zonename3, $entry->timestamp3, $this->zoneColors[$entry->zone4_id], $entry->zonename4, $entry->timestamp4, $this->zoneColors[$entry->zone5_id], $entry->zonename5, $entry->timestamp5, $this->zoneColors[$entry->zone6_id], $entry->zonename6, $entry->timestamp6, $this->zoneColors[$entry->zone7_id], $entry->zonename7, $entry->timestamp7, $this->zoneColors[$entry->zone8_id], $entry->zonename8, $entry->timestamp8, $this->zoneColors[$entry->zone9_id], $entry->zonename9, $entry->timestamp9, $this->zoneColors[$entry->zone10_id], $entry->zonename10, $entry->timestamp10, $this->zoneColors[$entry->zone11_id], $entry->zonename11, $entry->timestamp11); Now if I do a var_dump of the values I get values until I get to the point where they are populated. At that point I get a null value. Any one got any ideas Link to comment https://forums.phpfreaks.com/topic/88285-solved-array-issue/ Share on other sites More sharing options...
btherl Posted January 28, 2008 Share Posted January 28, 2008 What is this code intended to do? for ($i=0; $i<=11; $i++){ $this->zoneColors = $this->color[$i]; //var_dump($this->zoneColors); } $this->zoneColors = "#ffffff"; Link to comment https://forums.phpfreaks.com/topic/88285-solved-array-issue/#findComment-451752 Share on other sites More sharing options...
tigomark Posted January 28, 2008 Author Share Posted January 28, 2008 give a varible $thisZoneColor the value of each color so that it can then be turned into the value of entry->zone_id. zone$i_id is an integer value of 1-11. They need to be binded to the different colors Link to comment https://forums.phpfreaks.com/topic/88285-solved-array-issue/#findComment-451756 Share on other sites More sharing options...
btherl Posted January 28, 2008 Share Posted January 28, 2008 Can you try this out: for ($i=0; $i<=11; $i++){ $this->zoneColors[$i+1] = $this->color[$i]; //var_dump($this->zoneColors); } $this->zoneColors[$i+1] = "#ffffff"; The final #ffffff will be assigned to element 12 of the array. The first 11 values (from $this->color) will be assigned to elements 1-11 of the array. Is that what you're looking for? Link to comment https://forums.phpfreaks.com/topic/88285-solved-array-issue/#findComment-451761 Share on other sites More sharing options...
tigomark Posted January 28, 2008 Author Share Posted January 28, 2008 That's just what the doctor ordered thanks for the help. Link to comment https://forums.phpfreaks.com/topic/88285-solved-array-issue/#findComment-451765 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.