我想根据查询结果中显示的数据数量创建序号。 例如:
<?
$class_id=$_GET['class_no'];
$get_st=mysql_query("select * from students where calss_no='".$class_id."'");
if($get_st != 0) {
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\">$st_first_name $st_last_name </a>"."<br>";
}
}
?>
答案 0 :(得分:0)
我只是给出了这个概念。 这段代码没有结构化。
<?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 $st_last_name </a>"."<br>";
$sn++
}
}
?>