是否有任何方法可以从查询结果pre-While循环中获取第一个结果?

My site has a sizable table generated by a mysqli_query; the query includes a column 'messagetime':

$result = mysqli_query($cxn, 
"
  SELECT ......., messagetime
  FROM messages 
  ORDER by messagetime 
  DESC
"
);

I then generate the table (in php) with the help of a while loop:

echo "<table id='myTbl' class='newest' border='1'>";
echo "<th>Content</th> //etc.
echo "<tbody>";

while ($row = mysqli_fetch_assoc($result)) {

    // Fill the table body here

}

echo "</tbody></table>";

Nothing earth-shaking. However, the site uses polling to refresh the table, and I need to store the messagetime of the first result of the query in the table, like this:

echo "<table id='myTbl' class='newest".$newestTime."' border='1'>";

Right now, to capture the first (newest) messagetime, I am tweaking my While loop to do this:

$i = 0;
while ($row = mysqli_fetch_assoc($result)) {

     if ($i == 0) {
         echo "<table id='myTbl' class='newest".$row['messagetime']."' border='1'>";
         echo "<th>Content</th> //etc.
         echo "<tbody>";
     }

    // Fill the table here

     $i++;
}

echo "</tbody></table>";

However, this seems kind of hacky to me. Is there any way, without a subquery or union (since my query is actually the product of 2 joins, and is already expensive; this approach was described here), to simply pluck the first result from the query somehow, something like this?

$result = mysqli_query($cxn, 
"
  SELECT ......., messagetime, **first_messagetime_result AS newest_time**
  FROM messages 
  ORDER by messagetime 
  DESC
"
);

Thanks for any insight!

if ($result->num_rows > 0) {
    $row = mysqli_fetch_assoc($result)
    echo "<table id='myTbl' class='newest".$row['messagetime']."' border='1'>";
    echo "<thead><tr>";
    echo "<th>Content</th>"; //etc.
    echo "</tr></thead>";
    echo "<tbody>";
    do {
        // Fill the table here
    } while ($row = mysqli_fetch_assoc($result));
    echo "</tbody></table>";
}

You can simply call the first or other rows if you like before running it through the shile loop. The while loop will start with any rows that have not been called already. It's easy to forget that the while only exists to loop through the rows until it is done. We always could call a row from the query, but we institute the while to specifically do more.

All you need to do is this

$row = mysqli_fetch_assoc($result);

then you can do something like this to store the messagetime in a variable

$messagetime = $row;

and then you can use this variable how you like

After this instance the first row of your query has id of 1, when running the below, it will start with 2.

while ($row = mysqli_fetch_assoc($result)) { ... }