$sql = "SELECT date, index FROM table WHERE date='dateVal' AND index<'indexVal'
ORDER BY index ASC LIMIT 1";
$result = mysql_query($sql);
$row = mysql_fetch_row($result); //这里是正常情况,既有值
if(empty($row)){ //所谓的极端情况来了。。,既上一个有单日期的最后一单
$sql = "SELECT date, index FROM table WHERE date<'dateVal'
ORDER BY date,index DESC LIMIT 1";
$result = mysql_query($sql);
$row = mysql_fetch_row($result);
}
print_r($row);