我需要获取所选表格的第一行和特定列值:
$ttleft = '';
$st = $db->query("select * from recipes order by inde asc");
while($row = $st->fetch()){
$ttleft .= "<div class='ttleft'>" . $row['title'] . "</div>\n";
// result: 323 525 727 - that's ok
$ttop = $row['title'];
// result: 727 - I need 323
}
答案 0 :(得分:1)
如果您希望ASC订单中的$ttleft
和$ttop
等于最小
$ttleft = '';
$st = $db->query("select * from recipes order by inde asc");
while($row = $st->fetch()){
$ttleft .= "<div class='ttleft'>" . $row['title'] . "</div>\n";
// result: 323 525 727 - that's ok
if(!isset($ttop)){
$ttop = $row['title'];
//result: 323
}
}
否则,如果您不关心$ttleft
只是通过desc命令
$st = $db->query("select * from recipes order by inde desc");