您好我想使用codeigniter创建一个内部数据的棋盘。当我编程它时,我只能显示一个循环的黑色白板,如下面
我希望检查器看起来如下
希望这里的任何人都可以帮助我使用此代码。是否可以创建此检查器div?
这是我的代码:
<div class="be-content be-no-padding" >
<div class="main-content container-fluid">
<div class="row be-booking-promos">
<input type="hidden" name="<?= $this->security->get_csrf_token_name(); ?>" value="<?= $this->security->get_csrf_hash(); ?>" style="display: none" id="token">
<!-------- 1 -------->
<?php
$i = 1;
$j = 1;
$temp = true;
foreach ($prays as $row) {
?>
<div class="col-xs-6 col-md-2 col-xl-1">
<div class="card" id="card<?php echo $row->id; ?>" style="min-height:150px; max-height: 150px;
<?php
if ($row->status == 0) {
if ($i % 2 == 0) {
?>
background-color: #999"
<?php
} else {
?>
background-color: black"
<?php
}
} else {
?>
background-color: green"
<?php
}
?>
>
<div class="card-header" style="margin-bottom:-10px; color:white"><b><?php echo $row->name; ?></b></div>
<div class="card-body">
<p style="letter-spacing: 1px; color:white"><b><?php echo $row->prayNeed; ?></b></p>
</div>
</div>
</div>
<?php
$i+=1;
}
?>
</div>
</div>
</div>
答案 0 :(得分:0)
我找到了正确的脚本,让div像棋盘一样。因为我使用codeigniter,它必须在控制器中输入。
所以这是代码
public function viewListPray()
{
$idEvent=$this->input->cookie('eventID',False);
$pray=$this->pray->viewAllNewPray($idEvent);
$temp='';
$i=$this->input->post('countItem');
$color1="#999";
$color2="black";
$j=1;
foreach ($pray as $row) {
if ($i % 2 == 0) {
$temp .= '<div class="col-xs-6 col-md-2 col-xl-1">
<div class="card card-full" style="min-height:150px; max-height: 150px; background-color: ' . $color1 . '">
<div class="card-header" style="margin-bottom:-10px; color:white">' . $row->name . '</div>
<div class="card-body">
<p style="letter-spacing: 1px; color:white"><b>' . $row->prayNeed . '</b> </p>
</div>
</div>
</div>';
} else {
$temp .= '<div class="col-xs-6 col-md-2 col-xl-1">
<div class="card card-full" style="min-height:150px; max-height: 150px; background-color: ' . $color2 . '">
<div class="card-header" style="margin-bottom:-10px; color:white">' . $row->name . ' '.$j.'</div>
<div class="card-body">
<p style="letter-spacing: 1px; color:white"><b>' . $row->prayNeed . '</b> </p>
</div>
</div>
</div>';
}
$data = array(
'statusView' => 1
);
$id = $row->id;
if($i%12==0)
{
if($j==1)
{
$j=2;
}
else
{
$j=1;
}
}
if ($j == 1)
{
$color1="#999";
$color2="black";
}
else{
$color1="black";
$color2="#999";
}
$i+=1;
}
echo $this->security->get_csrf_hash().'|'.$temp.'|'.$i;
}