Why is the first html row hidden? Php/Mysql question

I’m making a kind of period-database, and this is my code:

$sqlQuery = "SELECT * FROM periods";
$result = mysqli_query($conn, $sqlQuery);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck > 0) {
	while ($row = mysqli_fetch_assoc($result)) {
		$id = $row['id'];
		$out = $row['fell_out'];
		$in = $row['fell_in'];
		$sum = $row['sum'];
		$nextEstimate = $row['next_estimate'];
		$nextEstimateDays = $row['next_estimate_days'];
		$notes = $row['notes'];

		$sqlQueryLastDate = "SELECT * FROM (select * from periods WHERE id < $id ORDER BY id DESC LIMIT 1) AS x ORDER BY id LIMIT 1";
		$resultLastDate = mysqli_query($conn, $sqlQueryLastDate);
		$resultCheckLastDate = mysqli_num_rows($resultLastDate);
		if ($resultCheckLastDate > 0) {
			while ($rowLastDate = mysqli_fetch_assoc($resultLastDate)) {
				$lastInDate = $rowLastDate['fell_in'];
			
				$sqlQueryCurrentDate = "SELECT * FROM (select * from periods WHERE id = $id ORDER BY id DESC LIMIT 1) AS x ORDER BY id LIMIT 1";
				$resultCurrentDate = mysqli_query($conn, $sqlQueryCurrentDate);
				$resultCheckCurrentDate = mysqli_num_rows($resultCurrentDate);
				if ($resultCheckCurrentDate > 0) {
					while ($rowCurrentDate = mysqli_fetch_assoc($resultCurrentDate)) {
						$currentOutDate = $rowCurrentDate['fell_out'];

						$lastIn = new DateTime($lastInDate);
						$currentOut = new DateTime($currentOutDate);
						$intervalLastCurrent = $lastIn->diff($currentOut);
						$elapsedLastCurrent = $intervalLastCurrent->format('%a days %h hours');
						/*Why? Php is erasing everything after adding the above variable to the table...Entire first row gets erased!*/
						echo "
								<tr>	
									<td>".$id."</td>
									<td class='test'>".$elapsedLastCurrent."</td> 
									<td class='dateOutResult'>".$out."</td>
									<td class='dateInResult'>".$in."</td>
									<td class='sumHours'>".$sum."</td>
									<td class='nextEstimate'>".$nextEstimate." (".$nextEstimateDays.")</td>
									<td class='notes'>".$notes."</td>
								</tr>";
					} /*$sqlQueryCurrentDate*/
				}
			} /*$sqlQueryLastDate*/
		}
	} /*$sqlQuery*/
}

So, let’s say I have 10 rows in my database. It’s only showing 9, the first row is not being displayed. When I changed this line: WHERE id < $id to WHERE id <= $id then the first row was displaying, however it was not giving the proper result. I hope someone can point me in the right direction. I’ll be here if I need to provide anymore details.

If you’re not getting the first id by doing id < $id and id <= $id is giving you unexpected results, have you tried id < $id - 1?

That is removing another row … Doing that now displays 8 rows instead of 10 :\