PHP分页表如何将显示更改为从上到下

PHP分页表如何将显示更改为从上到下,php,pagination,html-table,Php,Pagination,Html Table,我正在尝试创建PHP分页表。。但格式如下 ID:数据 备注:数据 日期:数据 但现在我的桌子是这样的: ID注释日期 数据数据 任何人都可以让我知道如何改变它吗。。。。。。。我的代码现在是这样的: <? $connection=Mysql_connect('XX','XX','XX'); if(!$connection) { echo 'connection is invalid';

我正在尝试创建PHP分页表。。但格式如下

ID:数据
备注:数据
日期:数据

但现在我的桌子是这样的:

ID注释日期
数据数据

任何人都可以让我知道如何改变它吗。。。。。。。我的代码现在是这样的:

<?
    $connection=Mysql_connect('XX','XX','XX');
            if(!$connection)
            {
                echo 'connection is invalid';
            }
            else
            {
                Mysql_select_db('XX',$connection);

            }
    //check if the starting row variable was passed in the URL or not
    if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) {
      //we give the value of the starting row to 0 because nothing was found in URL
      $startrow = 0;
    //otherwise we take the value from the URL
    } else {
      $startrow = (int)$_GET['startrow'];
    }
    //this part goes after the checking of the $_GET var
    $fetch = mysql_query("SELECT * FROM products LIMIT $startrow, 10")or
    die(mysql_error());
       $num=Mysql_num_rows($fetch);
            if($num>0)
            {
            echo "<table border=0  >";
            echo "<tr><td>ID</td><td>Drug</td><td>quantity</td></tr>";
            for($i=0;$i<$num;$i++)
            {
            $row=mysql_fetch_row($fetch);


            echo "<tr>";
              echo"<td>$row[1]</td>";

              echo"<td>$row[2]</td>";
             echo"<td>$row[3]</td>";
            echo"<td >$row[5]</td>";
            echo"</tr>";
            }//for
            echo"</table>";
            }
    //now this is the link..
    echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow+10).'">Next</a>';

    $prev = $startrow - 10;

    //only print a "Previous" link if a "Next" was clicked
    if ($prev >= 0)
        echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.$prev.'">Previous</a>';
    ?></td>
                   <td width="331">&nbsp;</td>
                 </tr>
               </table></td>
             </tr>
           </table>
           </td>
      </tr>
    <?php
        include("footer.php");
    ?>

对不起,现在就想办法

$row=mysql_fetch_row($fetch);
        echo "<tr>";
          echo"<td>ID:$row[1]</td>";
           echo "</tr>";
            echo "<tr>";
          echo"<td>Drug:$row[2]</td>";   echo "</tr>";  echo "<tr>";
         echo"<td>QTY:$row[3]</td>";   echo "</tr>";  echo "<tr>";
        echo"<td >Date:$row[5]</td>"
        ;echo "</tr>";  
        echo"</tr>"; echo"<tr height ='20'>";echo"</tr>";
        echo"<tr >";echo"</tr>";echo"<tr >";echo"</tr>";
        }//for
        echo"</table>";
        }
$row=mysql\u fetch\u row($fetch);
回声“;
回显“ID:$row[1]”;
回声“;
回声“;
echo“药品:$row[2]”;回声“;回声“;
回显“数量:$row[3]”;回声“;回声“;
echo“日期:$row[5]”
;回声“;
回声“;回声“;回声“;
回声“;回声“;回声“;回声“;
}//为了
回声“;
}
哦,我现在明白了

您可以通过以下方式实现:

<table cellpadding="0" cellspacing="0">
 <tr>
  <th>ID</th>
  <th>Comments</th>
  <th>Date</th>
 </tr>
 <?php 
  if(mysql_num_rows($recordsets) > 0){
   foreach ($recordsets as $recordset): 
 ?>
  <tr>
    <td><?php echo $recordset['id']); ?></td>
    <td><?php echo $recordset['comments']); ?></td>
    <td><?php echo $recordset['date']); ?></td>
   </tr>
  <?php 
      endforeach; 
    } else {
  ?>
  <tr>
   <td colspan="3">No records found !</td>
  </tr>
  <?php 
    }
  ?>
</table>

身份证件
评论
日期

您是否要求将
显示顺序
从上到下更改为
ASC/DESC
顺序?你的问题不太清楚我想是的我不想要ASC的正式表格。。