使用php在mysql中进行行编号

Is it possible to number rows in mysql using php? So not like with auto increment but with some type of code? I can do num_row() but it displays numbers based on how data is sorted in the table... but i would like data to be sorted by size for example, but numbered from 1 - oldest to X -newest.

I would actually like to manually give rows numbers... For example all inputs with id 10 should be numbered from 1-10 etc. (because i output data based on id)...

I tried with auto increment of a number but since all data is written in the same table, numbers dont go from 1 but from where it stopped (i deleten rows before) ... I need every output i do on a page to be numbered from 1-X.

To sum it up, i just want to create a counter to simulate an ordered list in a table, but every output should be numbered and then sorted by size: Screenshot attached how it should be. So first added is 1, second is 2...

if(!empty($_GET["orderby"])) {
    $orderBy = $_GET["orderby"];
}
if(!empty($_GET["order"])) {
    $order = $_GET["order"];
}
$randomNum = substr(str_shuffle("0123456789"), 0, 4);
$conn = mysqli_connect("localhost", "owjej_david", "dadadada", "owjej_kalkulator");
  // Check connection
  if ($conn->connect_error) {
   die("Connection failed: " . $conn->connect_error);
  } 
  $sql = "SELECT dolzina, sirina, kolicina,  opombe, povrsina, id, narocilo, cas FROM zunanje where id='$id' ORDER BY " . $orderBy . " " . $order;", cas asc";
  $result = $conn->query($sql);
  if ($result->num_rows > 0) {
          $rowNumber=0;
   // output data of each row
   while($row = $result->fetch_assoc()) {
           $rowNumber++;
    echo "<tr><td>" . 
    $rowNumber. "</td><td>" .
    $row["dolzina"] ." cm".'<a href="uredizunanjo.php?id=' . $row['id'] . '&uredi=dolzina&narocilo='. $row['narocilo'] . '&value='.$row['dolzina'].'"> &#9998;</a>'. "</td><td>" .
    $row["sirina"]." cm".'<a href="uredizunanjo.php?id=' . $row['id'] . '&uredi=sirina&narocilo='. $row['narocilo']  . '&value='.$row['sirina'].'"> &#9998;</a>'. "</td><td>" .
    $row["kolicina"].'<a href="uredizunanjo.php?id=' . $row['id'] . '&uredi=kolicina&narocilo='. $row['narocilo']  . '&value='.$row['kolicina'].'"> &#9998;</a>'. "</td><td>" .
    $row["opombe"].'<a href="uredizunanjo.php?id=' . $row['id'] . '&uredi=opombe&narocilo='. $row['narocilo']  . '&value='.$row['opombe'].'"> &#9998;</a>'. "</td><td>" .
    $row["povrsina"]." m&#xb2;".'<a href="updatepovrsina.php?id=' . $row['id'] . '&uredi=povrsina&narocilo='. $row['narocilo']  . '&value='.$row['povrsina'].'"> &#9998;</a>'. "</td><td>" .'
    <a href="izbrisizunanjo.php?id=' . $row['id'].'&narocilo='. $row['narocilo'].'">X</a>'."</td></tr>";}
echo "</table>";
} 
$conn->close();
?>