Merhaba, bir süredir bu ile uğraşan ve sizin yardımınıza ihtiyacımız ive. iyi ben veritabanından getirilen ne dayalı aşağıdaki verileri bir arada içeren bir dizi $ arrayAmenities var:
Air Conditioned
Bar
Brunch
Party Room
Tea Room
Terrace
Valet
I would like the application to dynamically check the following set of onay kutularını based on the data contained in the array. With my code only one checkbox is checked based on the first data contained in the array.
Eğer Im eksik ne söyleyebilir misiniz? Cevap için teşekkürler.
kodu:
//get amenities one by one in order to set the onay kutularını
$arrayAmenities = explode(',', $rest_amenities );
$i=0;
while(count($arrayAmenities) > $i)
{
var_dump($arrayAmenities[$i]);
switch($arrayAmenities[$i])
{
case 'Air Conditioned':
$checkedAir = 'checked=true';
break;
case 'Bar':
$checkedBar = 'checked=true';
break;
case 'Brunch':
$checkedBru = 'checked=true';
break;
case 'Party Room';
$checkedPar = 'checked=true';
break;
}
$i+=1;
}
}
onay kutularını
<table cellpadding="0" cellspacing="0" style="font-size:10px">
<tr>
<td style="border-top:1px solid #CCC;border-right:1px solid #CCC;border-left:1px solid #CCC; padding-left:5px ">Air Conditioned <input type="checkbox" name="air_cond" <?php print $checkedAir;?> value="Air Conditioned"></td>
<td style="padding-left:10px; border-top:1px solid #CCC;border-right:1px solid #CCC;">Bar <input type="checkbox" name="bar" value="Bar" <?php print $checkedBar;?>></td>
<td style="padding-left:10px; border-top:1px solid #CCC;border-right:1px solid #CCC; ">Brunch <input type="checkbox" name="brunch" value="Brunch" <?php print $checkedBru;?>></td>
</tr>
<tr>
<td style="border-top:1px solid #CCC;border-right:1px solid #CCC; border-bottom:1px solid #CCC; border-left:1px solid #CCC; padding-left:5px">Party Room <input <?php print $checkedPar;?> type="checkbox" name="party_room" value="Party Room" ></td>
<td style="padding-left:10px; border-top:1px solid #CCC;border-right:1px solid #CCC; border-bottom:1px solid #CCC;">Tea Room <input type="checkbox" name="tea_room" value="Tea Room" ></td>
<td style="padding-left:10px; border-top:1px solid #CCC;border-right:1px solid #CCC; border-bottom:1px solid #CCC;">Terrace <input type="checkbox" name="terrace" value="Terrace"></td>
</tr>
<tr>
<td colspan="3" style="border-bottom:1px solid #CCC; border-left:1px solid #CCC; border-right:1px solid #CCC; padding-left:5px">Valet <input type="checkbox" name="valet" value="Valet" ></td>
</tr>
</table>