记录未在此代码中删除 [英] record is not deleting in this code
本文介绍了记录未在此代码中删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
文件名:i.php
表格名称:emp
数据库名称:hari
file name:i.php
table name:emp
database name:hari
filelds in table:emp_id , first_name , last_name , emp_code , salary , age , date_of_joining , date_of_birth , dept_id , manager_id
<?php
$connection = mysql_connect("192.168.1.7","hari","hari");
mysql_select_db("hari");
$page_number=$_GET["pagenum"];
$per_page=2;
$result=mysql_query("select * from emp",$connection);
$num_rows=mysql_num_rows($result);
$total_pages=ceil($num_rows/$per_page);
$start=$per_page*($page_number-1);
$res= mysql_query("SELECT * FROM emp limit $start,$per_page");
echo "<a href = 'form.html'>ADD</a>";
echo "<table border=1>";
echo "<tr><th>emp_code</th>
<th>name</th>
<th>dept_id</th>
<th>action</th>
</tr>";
while($rec=mysql_fetch_assoc($res))
{
echo "<tr>";
echo "<td> $rec[emp_code]</td>";
echo "<td> <a href = 'db.php?emp_id = $rec[emp_id]'>$rec[first_name]</a></td>";
echo "<td> $rec[dept_id]</td>";
echo "<td> <a href = 'edit.php?emp_id = $rec[emp_id]'>edit</a>/<a href = 'i.php?emp_code = $rec[emp_code]'>delete</a> </td>";
echo "</tr>";
}
echo "</table>";
$a=$_GET["emp_code"];
$del = mysql_query("delete from emp where emp_code='$a' ");
for($i=1;$i<=$total_pages;$i++)
{
if($i==$page_number)
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$i'><b>$i</b></a> ";
else
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$i'>$i</a> ";
}
?>
推荐答案
连接 = mysql_connect(" ," ," ); mysql_select_db(" );
connection = mysql_connect("192.168.1.7","hari","hari"); mysql_select_db("hari");
page_number =
page_number=
_GET [" ];
_GET["pagenum"];
这篇关于记录未在此代码中删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文