在我的数据库的最后 table 行之前回显一个

echo one before the last table row from my database

这是我回显最后 table 行的代码。我想回显最后 table 行之前的一个和这段代码。任何机构都可以提供帮助?

我用它来显示我的应用程序中的 table 参数

    $conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
   //Checking if any error occured while connecting
 if (mysqli_connect_errno()) {
 echo "Failed to connect to MySQL: " . mysqli_connect_error();
die();
}
//creating a query
$stmt = $conn->prepare("SELECT name,family FROM student_list;");

//executing the query 
$stmt->execute();

//binding results to the query 
$stmt->bind_result(

$t1,
$t2

);
 $list = array(); 

 //traversing through all the result 
 while($stmt->fetch()){
 $temp = array();

$temp['t1'] = $t1;
$temp['t2'] = $t2;

array_push($list, $temp);
}

//displaying the result in json format 
 echo json_encode($list);

您可以使用 limit 获取 table 的倒数第二行。

SELECT name,family FROM student_list ORDER BY id DESC LIMIT 1,1