<?php
$dbname = "fspz";
$user = "htgl";
$link = mysql_connect("localhost:3306","root","123");
mysql_query("set names utf8");
mysql_query("use $dbname");
$sql = "select * from $user";
$result = mysql_query($sql);
if(!empty($_GET['id'])){
$id = $_GET['id'];
$sql = "delete from htgl where user_id = $id";
$result = mysql_query($sql);
if($result === false){
echo "<br />抱歉,删除失败,请参考" ;
}
else{
echo "<br /> 删除成功!";
}
}
echo "<table border = '1'>";
$field_count = mysql_num_fields($result);
echo "<tr>";
for($i = 0;$i < $field_count-1;++$i){
$field_name = mysql_field_name($result,$i);
if($i == $field_count-2){
echo "<th>" . $field_name . "<th>操作</th>" ."</th>";
}
else{
echo "<th>" . $field_name . "</th>";
}
}
echo "</tr>";
while($rec = mysql_fetch_array($result)){
echo "<tr>";
for($i = 0;$i < $field_count-1;++$i){
$field_name = mysql_field_name($result,$i);
if($i == $field_count-2){
echo "<td>" . $rec[$field_name] . "</td>" . "<td>" . "<a href='htgl.php?id={$rec['user_id']}' onclick='return queren()'>删除</a>"."</td>" ;
}
else{
echo "<td>" . $rec[$field_name] . "</td>";
}
}
}
echo "</tr>";
echo "</table>";
?>
捷克轩
Anachronism