PHP 清空 MySql 指定数据表中的所有数据

PHP 清空 MySql 指定数据表中的所有数据,在小编在网上闲逛时,这是某技术博客的一篇文章,说是文章,并没有文字,只有代码,经过测试可以使用,现在分享给大家。

共有三个文件,其实也可以合并写成一个。

1.conn.php:

Copy to ClipboardLiehuo.Net Codes引用的内容:[www.veryhuo.com]
<?php
$id=mysql_connect("localhost","root","mysql") or die(‘连接失败:’ . mysql_error());
if(mysql_select_db("phpjcdb",$id)) //说明:phpjcdb 是数据库名称
echo "";
else
echo (‘数据库选择失败:’ . mysql_error());
mysql_query("set names gb2312"); //设置为简体中文
?>

2.index.php: 

Copy to ClipboardLiehuo.Net Codes引用的内容:[www.veryhuo.com]
<?php
include("conn.php");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>清空指定数据表中的所有数据</title>
<style type="text/css">
<!–
.STYLE2 {font-size: 13px}
.STYLE3 {font-size: 12px}
–>
</style>
</head>
<script language="javascript" type="text/javascript">
function deletes(){
if (window.confirm(‘确定要删除该记录??’)==true){
return true;
}else{ return false;}
}
</script>
<body>
<form action="index.php" method="post" name="form1" id="form1">
<table width="614" height="90" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="20" height="53"> </td>
<td width="219"> </td>
<td width="355"> </td>
<td> </td>
</tr>
<tr>
<td height="26"> </td>
<td align="right"><select name="select">
<?php
$result = mysql_list_tables ("db_database06");
$i = 0;
while ($i < mysql_num_rows ($result)) {
$tb_names = mysql_tablename ($result, $i);
?>
<option value="<?php echo $tb_names;?>"><?php echo $tb_names;?></option>
<?php $i++; }?>
</select> </td>
<td><input type="submit" name="Submit2" value="提交" /></td>
<td width="20"> </td>
</tr>
<tr>
<td height="5"> </td>
<td align="right"> </td>
<td> </td>
<td> </td>
</tr>
</table>
<table width="614" height="25" border="0" cellpadding="0" cellspacing="0" background="images/bg03.jpg">
<tr>
<td width="20"> </td>
<td width="569">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<?php
if($_POST[‘Submit2’]=="提交"){
$select = $_POST[‘select’];
$query1=mysql_query("select * from $select");
$query2=mysql_query("select * from $select");
$myrow=mysql_fetch_row($query2);?>
<tr>
<?php for($i=0;$i<count($myrow);$i++){?>
<td align="center">
<span class="STYLE2"> <?php echo mysql_field_name($query2,$i);?></span></td>
<?php } ?>
</tr>
<?php while($myrow=mysql_fetch_row($query1)){ ?>
<tr>
<?php for($i=0;$i<count($myrow);$i++){?>
<td align="center"><span class="STYLE3"> <?php echo $myrow[$i];?></span></td>
<?php } ?>
</tr>
<?php } } ?>
</table></td>
<td width="20"> </td>
</tr>
</table>
</form>
<form action="index_ok.php?lmbs=<?php echo $select;?>"
method="post" name="form2" id="form2" onSubmit="return deletes();">
<table width="614" height="28" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center"><input type="submit" name="Submit" value="删除数据"></td>
</tr>
</table>
</form>
</body>
</html>

3.index_ok.php:

Copy to ClipboardLiehuo.Net Codes引用的内容:[www.veryhuo.com]
<?php
session_start();
include("conn.php");
if($_POST[‘Submit’]==true){
$lmbs = $_GET[‘lmbs’];
$result=mysql_query("delete from $lmbs");
if($result==true){echo "删除成功!";}else{echo "删除失败!!";}
}
?>
波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!

波比源码 » PHP 清空 MySql 指定数据表中的所有数据

2 评论

  1. Everything is very open and very clear explanation of issues. was truly information. Casibom , Casibom Giriş , Casibom Güncel Giriş , Casibom yeni adres . <a href="https://seowebtasarim.net/casibom/&quot; title="Casibin

  2. Thank you for great article. Hello Administ . Casibom Resmi Adresimiz için Tıklayin. ! casibom

评论已关闭

Hi, 如果你对这款模板有疑问,可以跟我联系哦!

联系站长
赞助VIP 享更多特权,建议使用 QQ 登录
喜欢我嘛?喜欢就按“ctrl+D”收藏我吧!♡