ShadowMage Posted April 5, 2012 Share Posted April 5, 2012 I am trying to generate a list of drop downs using a series of loops. I did not think this would be a problem, but the following keeps timing out at 60 secs: for ($x=0; $x<$types; $x++) { //$types = 20 $html.="<tr class='rightAlign'>\n"; $value = ''; if (isset($this->Description[$x])) { $value = $this->Description[$x]; } $html.="<td><input type='text'".$class." maxlength='25' tabindex='".($tabStop++)."' id='Description".($x+1).$setID."' name='Description[".$x."]' value='".$value."' style='width: 200px;' /></td>\n"; $html.="<td>\n"; if ($hover != 0) { $desc = ''; if (!empty($this->Assembly[$x])) { $desc = $this->Assembly[$x]; } $html.="<span".$class." style='display: inline-block; width: 50px;'>".htmlentities($desc, ENT_QUOTES)."</span>\n"; } else { $html.="<select name='CompAssembly[".$x."]' id='CompAssembly".($x+1).$setID."' tabindex='".($tabStop++)."'".$class." style='width: 70px;' >\n"; $html.="<option value='0'>None</option>\n"; //******************************************************************************** foreach ($arrAssemblies as $Assm => $Details) { //153 assemblies $assmTypes = explode(';', strtolower($Details['AssemblyType'])); $selected = ''; if ($Assm == $this->Assembly[$x]) { $selected = " selected='selected'"; } $PartList = ''; for ($x=0; $x<ASSM_PART_CNT; $x++) { //5 parts per assembly if ($Details['Part'.($x+1)] != '') { if ($PartList != '') { $PartList.="; "; } $PartList.=$Details['Part'.($x+1)]; } } //Add tube sizes and i-beam descriptions to part list tooltip if (in_array('tube', $assmTypes) || in_array('ibeam', $assmTypes) || in_array('ibeamdbl', $assmTypes)) { $PartList.= ' - '.$Details['Notes']; } $html.="<option value='".$Assm."' title='".$PartList."'".$selected.">".$Assm."</option>\n"; } //******************************************************************************** // $html.=$AssmList; $html.="</select>\n"; } $html.="</td>\n"; $value = ''; if (isset($this->Length[$x]) && ($this->Length[$x] > 0)) { $value = $this->Length[$x]*12; } $html.="<td><input type='text'".$class." tabindex='".($tabStop++)."' id='Length".($x+1).$setID."' name='Length[".$x."]' value='".$value."' style='width: 50px;' /></td>\n"; $value = ''; if (isset($this->Quantity[$x]) && ($this->Quantity[$x] > 0)) { $value = $this->Quantity[$x]; } $html.="<td><input type='text'".$class." tabindex='".($tabStop++)."' id='Quantity".($x+1).$setID."' name='Quantity[".$x."]' value='".$value."' style='width: 50px;' /></td>\n"; $html.="</tr>\n";} If I remove the marked section from the outer loop and populate the $AssmList variable with the options instead, it works just fine. Only one problem: I can't set the selected option because I need to use the $x from the outer loop to check $this->Assembly[$x] and obviously I can't do that outside of the outer loop.I can understand that taking this section out takes less time (15300 iterations vs 785) though I didn't think 15k iterations would take quite that long.Anyway, the question is, how do I get this to run within the 60 second timeframe and still be able to set the selected options? Boy I hope all that made sense.... Link to comment Share on other sites More sharing options...
astralaaron Posted April 5, 2012 Share Posted April 5, 2012 I did not test this or anything but maybe it has something to do with using $x as the incrementing variable for a loop within a loop already using $x. at first glance it looks like the main loop is never ending Link to comment Share on other sites More sharing options...
ShadowMage Posted April 5, 2012 Author Share Posted April 5, 2012 Well, golly jee...That did it. Thx, astralaaron! Can't believe I missed that... Link to comment Share on other sites More sharing options...
thescientist Posted April 5, 2012 Share Posted April 5, 2012 Well, golly jee...That did it. Thx, astralaaron! Can't believe I missed that... n00b Link to comment Share on other sites More sharing options...
ShadowMage Posted April 5, 2012 Author Share Posted April 5, 2012 n00b Yeah, that's what I was thinking! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.