agito
(The3cube)
1
goodday everyone;
i’ve some problem to show data from my database, it used to create form with dynamic input name (same on database settings)
- Database Structure
idDiyTemplate,set1, set2, set3, etc…
- Problem = show looping w/ syntax while (on bold),
<?
$sql=“SELECT * FROM diyTemplate WHERE idDiyTemplate=‘1’”;
$post=DiyTemplate::model()->findBySql($sql);
$setting=$post->jmlSetting;
$set=1;
[indent]
while ($setting >= ‘1’){
?>
[indent]
<tr>
<td width="100"><? echo $post->set[$set]; ?></td>
<td>
<input name="<? echo $post->set1; ?>" size="30" type="text" />
</td>
</tr>
[/indent]
<?
echo $setting."-";
$set++;
$setting--;
}
?>
[/indent]
how can i fix this?
thanks so much to advices;
check
while ($setting >= '1'){
you cannot assign string to compare >= it should be while ($setting >= 1)
agito
(The3cube)
3
Hi Absar A Hasan,
thanks for advice,
but it’s still work to compare it, 
agito
(The3cube)
4
PROBLEM SOLVED
it can not be used variable on it = $post->set[$set]
i used $set=set1; and adding value 1 ($set++
on loop, and it works,
<?
$sql="SELECT * FROM diyTemplate WHERE idDiyTemplate='1'";
$post=DiyTemplate::model()->findBySql($sql);
$setting=$post->jmlSetting;
$set=set1;
while ($setting >= 1){
?>
<tr>
<td width="100"><? echo $post->$set; ?></td>
<td>
<input name="<? echo $post->$set; ?>" size="30" type="text" />
</td>
</tr>
<?
echo $setting."-";
$set++;
$setting--;
}
The results are = set1, set2, set3, …
Thanks Yii ,
and special to Absar A Hasan, thanks dude 
alirz23
(Alirz23)
5
why don’t you just use a simple
foreach