如何在php中显示序列号

如何在php中显示序列号,php,Php,我想根据查询结果中显示的数据数量创建序列号。 例如: 1-大卫 2-艾哈迈德 3-詹姆斯 我只是给出概念。 此代码不是结构化的 <?php $class_id=$_GET['class_no']; $get_st=mysql_query("select * from students where calss_no='".$class_id."'"); if($get_st != 0) { $sn = 1;

我想根据查询结果中显示的数据数量创建序列号。 例如:

1-大卫 2-艾哈迈德 3-詹姆斯 我只是给出概念。 此代码不是结构化的

    <?php
    $class_id=$_GET['class_no'];

        $get_st=mysql_query("select * from students where calss_no='".$class_id."'");
        if($get_st != 0) {
         $sn = 1;
            while($row=mysql_fetch_array($get_st)) {

                 $st_no=$row['st_no'];
                 $st_first_name=$row['st_first_name'];
                 $st_last_name=$row['st_last_name'];
                 $calss_no=$row['calss_no'];
                 $super_no=$row['super_no'];

                    echo"<a href=\"st_page.php?st_no=$st_no\">$sn - $st_first_name &nbsp;&nbsp;$st_last_name </a>"."<br>"; 
                $sn++       
            }

        }


?>

您不知道如何增加一个数字并将其添加到输出中?也迫不及待地想在这里访问page.php?class\u no=some\u sql\u injection\u。
    <?php
    $class_id=$_GET['class_no'];

        $get_st=mysql_query("select * from students where calss_no='".$class_id."'");
        if($get_st != 0) {
         $sn = 1;
            while($row=mysql_fetch_array($get_st)) {

                 $st_no=$row['st_no'];
                 $st_first_name=$row['st_first_name'];
                 $st_last_name=$row['st_last_name'];
                 $calss_no=$row['calss_no'];
                 $super_no=$row['super_no'];

                    echo"<a href=\"st_page.php?st_no=$st_no\">$sn - $st_first_name &nbsp;&nbsp;$st_last_name </a>"."<br>"; 
                $sn++       
            }

        }


?>