我认为很多人都可以解决这个问题。有人请帮我在bil栏中显示数字。使它显示为1 2 3 4 5而不是从数据库中获取它。这是代码:
<?php
session_start(); //starts the session
if($_SESSION['id']){ // checks if the user is logged in
}
else{
header("location: index.php"); // redirects if user is not logged in
}
$id = $_SESSION['id']; //assigns user value
?>
<html>
<head>
<title>Sistem Laporan</title>
</head>
<body><div align="center">
<center><img src="pic/latestbanner.jpg" width="1000" height="150" border="3"></center>
<table width="1004" border="1">
<tr>
<td width="98"><center><a href="home.php">Laman Utama</a></center></td>
<td width="554" height="30"><center>Log masuk sebagai <?php Print "$id"?>!</center>
<!--Displays user's name--> </td>
<td width="162"><center><a href="tukar_password.php">Kata Laluan</a></center></td>
<td width="164"><center><a href="logout.php">Log Keluar</a></center></td>
</tr>
</table></div>
<center><table width="1000" height="346" border="1">
<tr>
<td>
<center><table width="993" height="324" border="0">
<tr>
<td colspan="3" height="27"><a href="home.php">Laman Utama</a> >
<a href="pengurusan_sistem.php">Pengurusan Sistem</a> > <a href="senarai_pengguna.php">
Senarai Pengguna</a></td>
</tr>
<tr>
<td width="157"> </td>
<td width="585"> </td>
<td width="237"> </td>
</tr>
<tr>
<td align="center"><input type="button" value="Kembali" onclick="window.location.href='pengurusan_sistem.php'"></td>
<td> </td>
<td align="center"><input type="button" value="Daftar Pengguna Baru" onclick="window.location.href='register.php'"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr valign="top">
<td colspan="3" height="235"><center><table border="1px" width="95%">
<tr>
<th width="4%">Bil</th>
<th width="7%">ID Pengguna</th>
<th width="6%">Kata Laluan</th>
<th width="7%">Tahap Pengguna</th>
<th width="25%">Nama & Emel</th>
<th width="10%">No KP</th>
<th width="9%">Telefon Pejabat</th>
<th width="9%">Sektor</th>
<th width="8%">Jawatan</th>
<th width="8%">Kemaskini</th>
<th width="7%">Buang</th>
</tr>
<?php
mysql_connect("localhost", "root","") or die(mysql_error()); //Connect to server
mysql_select_db("sistem_laporan") or die("Cannot connect to database"); //connect to database
$query = mysql_query("Select * from profil"); // SQL Query
$reset = mysql_query("ALTER TABLE profil AUTO_INCREMENT = 1"); //reset auto increment
while($row = mysql_fetch_array($query))
{
Print "<tr>";
Print '<td align="center">'. $row['bil'] . "</td>";
Print '<td align="center">'. $row['id'] . "</td>";
Print '<td align="center">'. $row['katalaluan']. "</td>";
Print '<td align="center">'. $row['level'] . "</td>";
Print '<td align="center">'. $row['nama'] ."<br/>". $row['emel'] . "</td>";
Print '<td align="center">'. $row['noKp']. "</td>";
Print '<td align="center">'. $row['noPej']. "</td>";
Print '<td align="center">'. $row['sektor']. "</td>";
Print '<td align="center">'. $row['jawatan']. "</td>";
Print '<td align="center"><a href="updateUser.php?bil='. $row['bil'] .'">kemaskini</a></td>';
Print '<td align="center"><a href="#" onclick="delFunc('.$row['bil'].')">buang</a> </td>';
Print "</tr>";
}
?>
<script>
function delFunc(bil)
{
var r=confirm("Anda pasti ingin membuang rekod pengguna ini?");
if (r==true)
{
window.location.assign("delete_pengguna.php?bil=" + bil);
}
}
</script>
</table></center></td>
</tr>
<tr>
<td height="46"> </td>
<td> </td>
<td> </td>
</tr>
</table></center>
</td>
</tr>
</table></center>
<center><?php require_once('footer.php'); ?></center>
</body>
</html>
在那里你可以看到我正在$ row ['bil']从数据库中检索bil列。但是我想让你帮助我把它变成像bil列上的row ++那样它将是1 2 3 4 5按升序排列。感谢错误的英语