I'm doing a campaign project in which the admin can reserve some seats using admin panel. When he wants to edit it,previously selected seats should highlight. This is what i've done for achieving this
if ($mode == 'EDIT')
{
$k=1;
for($i=1;$i<=10;$i++)
{
for($j=1;$j<=10;$j++)
{ ?>
<div id='<?php echo $k ;?>' class="seat_selection"
<?php foreach($seat_data as $seats)
{
if($seats->iSeatNumber == $k)
{?>
style='min-height:25px;min-width:25px;background-color:#12B22F;float:left;margin:0 0 5px 10px;cursor:pointer;'
<?php
}
else
{?>
style='min-height:25px;min-width:25px;background-color:#969696;float:left;margin:0 0 5px 10px;cursor:pointer;'
<?php
}
}
?>
>
<?php echo $k;?>
</div>
<?php $k++;
} ?>
<br /><br />
<?php
}
}
But only the first seat among the selected seats is being highlighted(like 5th seat as shown in screenshot). Rest remains unchanged.
Screenshot
I think the problem is with the looping of foreach
. Am i doing it in the wrong way? Or is there any other method? Any help would be greatly appreciated.
I'm using datamapper
(db operations) for codeigniter
(php framework).