I can not understand why the first line disappears when the table is displayed. That is, there is a list where let's say: Ivanov, Petrov, Sidorov. And everything is displayed starting from Petrov.

<?php $myCmd = "SELECT * FROM dlpodrazdeleniya, dldoctor, dlSpec, dltime WHERE id='$cat' AND dldoctor.idPodr = dlpodrazdeleniya.idPodr AND dldoctor.SpecID = dlSpec.SpecID AND dldoctor.DoctorID = dltime.DoctorID"; $buf = mysql_query($myCmd); echo "<table class='sortable1' id='table'>\n"; echo "<tr align='center'>\n"; if (!empty($buf['Ychastok'])) { echo "<th>Участок</th>\n"; } if (!empty($buf['Cabinet'])) { echo "<th>Кабинет</th>\n"; } echo "<th>ФИО врача</th>\n"; echo "<th>Специалист</th>\n"; echo "</tr>\n"; for($i=1; $i<=mysql_num_rows($buf); $i++) { $row = mysql_fetch_array($buf); echo "<tr align='center'>\n"; if (!empty($row['Ychastok'])) { echo "<td><font color=red>".$row['Ychastok']."</td>\n"; } if (!empty($row['Cabinet'])) { echo "<td><font color=red>".$row['Cabinet']."</td>\n"; } echo "<td><font color=red>".$row['LastName']." ".$row['FirstName']." ".$row['MiddleName']."</td>\n"; echo "<td><font color=red>".$row['SpecName']."</font color></td>\n"; echo "</tr>\n"; } echo "</table>\n"; ?> 

    1 answer 1

    The score starts from 0, not from 1:

     for($i=0; $i<=mysql_num_rows($buf); $i++)