Forum Moderators: coopster

Message Too Old, No Replies

Need to make the for loop work

         

ahmedwaseem2000

6:19 am on Jul 19, 2005 (gmt 0)

10+ Year Member



Hi , Can any one tell me how to execute the below mentioned for loop. as i am not able to do so and also i have tried with foreach and while statements it seems like the comparison and increament and intialization doesnt work here. $combval is the array variable which has got multiple values. and with the second snippet of the code i am able to load the first value of the array vairable

$sHTML = $sHTML."<td style='".$this->gcColumnDetail[$j]->sColumnStyle
.$this->regRowStyle."'><select name =combo$cntrl_count_comb"
.$this->gcColumnDetail[$j]->sShowValue."\" value='"
.$rsRow[$this->gcColumnDetail[$j]->iColumnPosition].
"'>
for ($y=0; $y<$num_rows; eval($y=$y+1) )
{
<option >$combval[$y]</option>
eval($y= $y +1)
}
</select>
</td>";

************************************************

$sHTML = $sHTML."<td style='".$this->gcColumnDetail[$j]->sColumnStyle
.$this->regRowStyle."'><select name =combo$cntrl_count_comb"
.$this->gcColumnDetail[$j]->sShowValue."\" value='"
.$rsRow[$this->gcColumnDetail[$j]->iColumnPosition].
"'>
'for ($y=0; $y < $num_rows; $y++ )
{'
<option > $combval[$y] </option>
'}'
</select>

</td>";

PLEASE HELP!

mcibor

8:41 am on Jul 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$sHTML .= "<td style=\"".$this->gcColumnDetail[$j]->sColumnStyle
.$this->regRowStyle."\"><select name=\"combo$cntrl_count_comb"
.$this->gcColumnDetail[$j]->sShowValue."\" value=\""
.$rsRow[$this->gcColumnDetail[$j]->iColumnPosition].
"\">";
for ($y = 0; $y < $num_rows; $y++)
{
$sHTML .= "<option>".$combval[$y]."</option>";
}
$sHTML .= "</select>
</td>";

This will work. for is a loop, and shouldn't be put inside the string declaration.

Michal Cibor

PS. Welcome to webmasterworld

PS. You can also use this format:

$sHTML .= "<td style=\"{$this->gcColumnDetail[$j]->sColumnStyle}
{$this->regRowStyle}\"><select name=\"combo$cntrl_count_comb
{$this->gcColumnDetail[$j]->sShowValue}\" value=\"
{$rsRow[$this->gcColumnDetail[$j]->iColumnPosition]}
\">";

Whatever you prefer.