多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > php教程 > PHP 清空 MySql 指定數據表中的所有數據

PHP 清空 MySql 指定數據表中的所有數據

來源:程序員人生   發布時間:2014-04-08 11:51:35 閱讀次數:3277次

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 "刪除失敗!!";}
}
?>
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 奇奇网免费影视片 | 尤物视频在线观看免费视频 | 999精品免费视频 | 亚洲综合激情另类小说区 | 99视频精品免视3 | 日韩欧美亚洲视频 | 国产真实乱小说 | 欧美国产日韩精品 | www在线播放 | 最近最新高清中文字幕 | 淫片在线观看 | 欧美精品v国产精品v | 亚洲欧美国产视频 | 成人性生免费视频 | 最近中文字幕大全高清在线 | 国产精品乱码免费一区二区 | 久草综合在线 | 拍拍拍在线观看视频免费 | 亚洲国产精品人久久 | 黄色a网站| 91精品欧美一区二区三区 | 大香人蕉免费视频75 | 国产成年网站v片在线观看 国产成人 免费观看 | 欧美日韩免费 | 亚洲在线免费视频 | 图片区小说区激情区偷拍区 | 琪琪在线影院 | 欧美网站色 | 欧美精品 日韩 | 日本护士xxx| 精品国产午夜久久久久九九 | 久久精品免观看国产成人 | 国产福利视频一区二区 | 欧美一级毛片不卡免费观看 | 国产偷v国产偷v亚洲高清 | 欧美精品久久久久久久影视 | 波多野结衣资源在线 | xxxx18日本护士hd| 国产精品久久久久激情影院 | 国内小情侣一二三区在线视频 | 操操网址|