Rumah > Artikel > pembangunan bahagian belakang > php里面怎么循环嵌入html元素
<li data-role="collapsible"> <h1>中奖信息</h1> <ul> <?php $sql = "select * from t_activity where MemberID='$memberID'"; $res = $db->GetData($sql); while ($obj = mysqli_fetch_object($res)) { ?> <li><?php echo $obj->字段 ;?></li> <?php } ?> </ul> </li>
<li data-role="collapsible"> <h1>中奖信息</h1> <ul> <?php $sql = "select * from t_activity where MemberID='$memberID'"; $res = $db->GetData($sql); while ($obj = mysqli_fetch_object($res)) { ?> <li><?php echo $obj->字段 ;?></li> <?php } ?> </ul> </li>
<li data-role="collapsible"> <h1>中奖信息</h1> <ul> <?php $sql = "select * from t_activity where MemberID='$memberID'"; $res = $db->GetData($sql); while ($obj = mysqli_fetch_object($res)) { ?> <li><?php echo $obj->字段 ;?></li> <?php } ?> </ul> </li>
<li data-role="collapsible"> <h1>中奖信息</h1> <ul> <?php $sql = "select * from t_activity where MemberID='$memberID'"; $res = $db->GetData($sql); while ($obj = mysqli_fetch_object($res)) { ?> <li><?php echo $obj->字段 ;?></li> <?php } ?> </ul> </li>
打印出来1,但数据库有3条
把count(*)换成* 就可以了
或者这样也可以
$row = mysqli_fetch_row($res);$num = $row[0];
打印出来1,但数据库有3条
把count(*)换成* 就可以了
大神!
$num = mysqli_fetch_row($res);
echo $num[0];
或者
list($num) = mysqli_fetch_row($res);
或者
$num = crrrent(mysqli_fetch_row($res));