我想使用insertItemsAtIndexPaths
循环生成项目列表。项目列表将显示在下拉菜单中的标题元素下。
这是我的代码:
insertItemsAtIndexPaths
但问题是:
for
- 循环与PHP中的字符串连接起来。
<div class="container div_scroll">
<?php if($data->results()){
?>
<div class="row">
<div class="panel panel-default">
<div class="panel-heading ">
<h4 class="panel"> <?php echo $state_decode . ' : ' . count($data -> results()); ?>
</h4>
</div>
<table class="table table table-striped table-bordered table-hover">
<thead>
<tr>
<th class="col-md-1">S.N.</th>
<th class="col-md-1">ENQ No</th>
<th class="col-md-1">ENQ Date</th>
<th class="col-md-3">ENQ Descr</th>
<th class="col-md-1">Tender Ref</th>
<th class="col-md-2">Cust Name</th>
<th class="col-md-2">Project Name </th>
<th class="col-md-1">Action</th>
</tr>
</thead>
<tbody>
<?php
switch($state) {
case "draft" :
$heading = 'Edit';
$url = array('new_eis_form1.php','http://google.com');
$menu = array('Modify','Attach Files','Add Equipment');
$param = '';
$btn = array('btn btn-info','btn btn-info','btn btn-info');
$id_name = 'enq';
break;
case "submit" :
$url = 'http://google.com';
$action = 'View';
$param = '';
break;
break;
case "recvd" :
$url = 'new_eis_form1.php';
$action = 'Edit';
$param = '';
break;
case "not_recvd" :
$url = 'new_eis_form1.php';
$action = 'Edit';
$param = '';
break;
case "hold" :
$url = 'new_eis_form1.php';
$action = 'Edit';
$param = '';
break;
case "wo1_pend" :
$url = 'new_eis_form1.php';
$action = 'Edit';
$param = '';
break;
case "cancel" :
$url = 'new_eis_form1.php';
$action = 'Edit';
$param = '';
break;
}
foreach ($data -> results() as $test) {
$param = $test -> ENQ_NO;
echo "<tr>
<td class=\"col-md-1\">" . ++$slno . "</td>
<td class=\"col-md-1\">" . $test -> ENQ_NO . "</td>
<td class=\"col-md-1\">" . $test -> ENQ_DATE . "</td>
<td class=\"col-md-3\">" . $test -> ENQ_DESR . "</td>
<td class=\"col-md-1\">" . $test -> TENDER_REF_NO . "</td>
<td class=\"col-md-2\">" . $test -> CUST_NAME . "</td>
<td class=\"col-md-2\">" . $test -> PROJ_NAME . "</td>
<td class=\"col-md-1\"><div class=\"dropdown\">
<button class=\"btn btn-primary dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\">".$heading."
<span class=\"glyphicon glyphicon-th-list\"></span>
<span class=\"caret\"></span></button>
<ul class=\"dropdown-menu pull-right\">".
for($i=0;$i<count($menu);$i++){echo "<li><a href=\".$url[$i]."?".$id_name."=".$param.\">".oper($menu[$i],$btn[$i])."</a></li>";
}
"</ul>
</div></td>
<td class=\"col-md-2\"></td>
</tr>";
/* oper() function is in coomon.php; uses two inputs one is btn display label and oter is btn style class */
}
// }
?>
</tbody>
</table>
</div>
</div>
<?php }else{ ?>
<div class="row">
<div class="panel panel-primary">
<div class="panel-heading ">
<h4 class="panel">Alert</h4>
</div>
<div class="panel panel-body">
<h4 class="body panel">There is no enquiry; If you want to add enquiry details please <a href="eis_form_eqp.php"><span class="glyphicon glyphicon-link "><u>click here</u></span> </a>.</h4>
</div>
</div>
</div>
<?php } ?>
</div>
答案 0 :(得分:1)
那样的东西?
$str = '';
for ($i = 0; $i < count($menu); $i++) {
$str .= '<li>
<a href="' . $url[$i] . '?'.$id_name.'='.$param.'">'. oper($menu[$i],$btn[$i]).'</a>
</li>';
}
$html = '<td class="col-md-1">
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle"
type="button" data-toggle="dropdown">'.$heading.'<span class="glyphicon glyphicon-th-list"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right">
' . $str . '
</ul>
</div>
</td>';