<?php
$stmt = $db->query("SELECT * FROM table LIMIT 5");
foreach ($AnB as $aB): ?>
<a href="#">
<div>
<h6>Number here</h6>
<h5><?php echo $aB['title'] ?></h5>
</div>
</a>
<?php endforeach; ?>
如您所见,我使用了LIMIT 5,我想在每个循环中放置一个数字,从1到5开始。
这应该是这样的:
答案 0 :(得分:6)
var GeofencingModel = require('../models/geofencing_areas.js');
const Zone = new GeofencingModel({
name:row.toString()+col.toString(),
type:'Polygon',
coordinates : [coordinates],
created_at: new moment.tz('Asia/Dubai').format('Y-M-D HH:mm:ss')
});
Zone.save((err, zones) => {
if (err) {
return false;
} else {
return true;
}
});
我使用了一个变量来保持计数。每次循环[ [ 55.18777533242337, 25.35359425987688 ],
[ 55.18777533242337, 55.287108408253516 ],
[ 55.287108408253516, 25.26372890279708 ],
[ 25.26372890279708, 25.35359425987688 ],
[ 55.18777533242337, 25.35359425987688 ] ]
<?php
$count = 1;
$stmt = $db->query("SELECT * FROM table LIMIT 5");
foreach ($AnB as $aB): ?>
<a href="#">
<div>
<h6><?php echo $count; ?></h6>
<h5><?php echo $aB['title'] ?></h5>
</div>
</a>
<?php $count++; endforeach; ?>
变量加1。