PHP管理系统

lixianwei6666 2010-05-24 09:24:16
各位高手大家好,请求高手帮我看看,最近小弟用PHP做一个图书管理系统的毕业设计,不知是什么原因,能找到要删除的记录就是删除不掉,还望高手能够帮忙解答,小弟不胜感激,代码如下



admin.php

<?
//######################管理员功能页##########################
include "config.php";?>
<?include "header.php";?>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<link href="style.css" rel="stylesheet" type="text/css">
<table width="770" border="0" cellspacing="1" cellpadding="0" bgcolor="#000000" align="center">
<tr>
<td bgcolor="#FFFFFF">
<div align="right" class="text"><font color="#FF0000"><a href="admin_query.php">管理员查询</a>‖<a href="book_admin.php">添加图书</a></font></div>
</td>
</tr>
</table>
<table width="770" border="0" cellspacing="1" cellpadding="0" bgcolor="#333333" align="center">
<tr>
<td bgcolor="#FFFFFF">
<div align="center" class="title">书名</div>
</td>
<td width=100 bgcolor="#FFFFFF">
<div align="center" class="title">作者</div>
</td>
<td bgcolor="#FFFFFF">
<div align="center" class="text">
<p>出版社</p>
</div>
</td>
<td width=65 bgcolor="#FFFFFF">
<div align="center" class="title">出版日期</div>
</td>
<td width="5%" bgcolor="#FFFFFF">
<div align="center" class="title">价格(元)</div>
</td>
<td width="9%" bgcolor="#FFFFFF">
<div align="center" class="title">分类号</div>
</td>
<td width=30 bgcolor="#FFFFFF" class="title">
<div align="center">册数</div>
</td>
<td width=30 bgcolor="#FFFFFF" class="title">
<div align="center">状态</div>
</td>
<td width="9%" bgcolor="#FFFFFF" class="title">
<div align="center">删除</div>
</td>
</tr>
<?
$n=0;
$query=mysql_query("select count(*) as sm from book_list ");
$row=mysql_fetch_array($query);
$count=$row[sm];
if(empty($offset))
{$offset=0;}

$query=mysql_query("select * from book_list order by book_id desc limit $offset,$list_num") or die ("fail");
while($row=mysql_fetch_array($query)){
if(($n%2)!='0'){
echo "<tr bgcolor=#FFFFff>";}
else{
echo "<tr bgcolor=#E4E4E4>";
}
echo"<td height='15'>
<div align='center' class='text'>".$row['book_name']."</div></td>
<td width=100 height='15' class='text'> <div align='center'>".$row['author']."</div></td>
<td height='15' class='text'> <div align='center'>".$row['pub_addr']."</div></td>
<td width=65 height='15' class='text'> <div align='center'>".$row['pub_date']."</div></td>
<td width='5%' height='15' class='text'><div align='center'>".$row['price']."</div></td>
<td width='9%' height='15' class='text'> <div align='center'>".$row['sort_id']."</div></td>
<td height='15' class='text'> <div align='center'>".$row['volumes']."</div></td>
<td width=30 height='15' class='text'> <div align='center'>".$row['status']."</div></td>
<td height='15' class='text'><div align='center'>
<a href=book_del.php?book_id=".$row['book_id'].">删除</a></div></td> //删除地方
</tr> ";
$n++;
}
?></table><?
$pages=ceil($count/$list_num);
echo "<table width=770 border=0 cellspacing=0 cellpadding=0 align=center class='text'>
<tbody>
<tr>
<td width='159'><font color='#ff0000'>目前共有:".$count." 条记录</font> </td>
<td width='205'>".$pages."页</td>";

if($offset){
$preoffset=$offset-$list_num;
print "<td width='132'><a href=\"$PHP_SELF?offset=$preoffset\">上一页</a></td>";}
else {
echo "<td width='132'>上一页</td>";
}
$newoffset=$offset+$list_num;
if(($pages!=0)&&(($newoffset/$list_num)!=$pages))
{
print("<td width='158'><a href=\"$PHP_SELF?offset=$newoffset\">下一页</a></td>");
}
else{ echo "<td width='158'>下一页</td>";}
$pageno=($offset/$list_num)+1;
echo "<td width='112' class=text>第<input class=text type='text' size='4'value=".$pageno." readonly>
页</td>
<td width='4'> </td></tr>
</table>";
?>
<?include "foot.php";?>


book_del.php
?<?
//######################管理员删除库中书##########################
include "config.php";
include "header.php";


$query="delete from $book_table where book_id='".$row['book_id']."'"; //执行删除操作的地方
$result=mysql_query($query);
if(!$result)
{
echo "对不起,删除不成功,请确认删除权限!";
echo "<meta http-equiv=\"refresh\" content=\"0;url=admin.php\">";
}else{
echo "<p align=\"center\">删除成功!<a href=admin.php>返回管理页面</a></p>\n";
}
include "foot.php";
?>
...全文
113 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
永生天地 2010-05-24
  • 打赏
  • 举报
回复
帮顶,这个没摸过
htl258_Tony 2010-05-24
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 lixianwei6666 的回复:]
$query="delete from $book_table where book_id='".$row['book_id']."'"; //执行删除操作的地方
$result=mysql_query($query);
if(!$result)
{
echo "对不起,删除不成功,请确认删除权限!";
echo "<meta http-equiv=\"refresh\"……
[/Quote]
ELSE后面有删除的动作吗
lixianwei6666 2010-05-24
  • 打赏
  • 举报
回复
$query="delete from $book_table where book_id='".$row['book_id']."'"; //执行删除操作的地方
$result=mysql_query($query);
if(!$result)
{
echo "对不起,删除不成功,请确认删除权限!";
echo "<meta http-equiv=\"refresh\" content=\"0;url=admin.php\">";
}else{
echo "<p align=\"center\">删除成功!<a href=admin.php>返回管理页面</a></p>\n";
}
include "foot.php";
?>

都执行了else语句,但就是没有删除选定的记录,数据库中的东西还在,为什么
--小F-- 2010-05-24
  • 打赏
  • 举报
回复
看不懂
htl258_Tony 2010-05-24
  • 打赏
  • 举报
回复
关于SQL的问题在哪里?
  • 打赏
  • 举报
回复
查php的错误日志看出了什么错
alisafan123 2010-05-24
  • 打赏
  • 举报
回复

34,587

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧