后台使用php,前台引用jquery,实现增删操作,代码如下:
复制代码 代码如下:
<script type="text/javascript" src="/UploadFiles/2021-04-02/jquery-1.10.2.min.js"><?php
header("Content-type: text/html; charset=utf-8");
//mysql_connect 建立连接,mysql_close($link)关闭非永久连接,mysql_pconnect 建立永久连接
//mysql_error返回mysql函数错误信息,mysql_errno返回mysql函数错误号码
//mysql_set_charset 设置用户端字符集,mysql_select_db 选择连接数据库
//mysql_query 执行查询,mysql_num_rows返回查询记录条数
//mysql_affected_rows返回受影响的记录条数,mysql_free_result 释放结果集内存
//mysql_fetch_row 返回列举阵列记录,mysql_fetch_assoc 返回关联阵列记录
//mysql_fetch_array 返回关联阵列或数字阵列记录,mysql_fetch_object 返回物件形式记录
//mysql_fetch_result 取得结果集资料
//%s 字符串,%c 一个ASCII字符,%d 一个整数,%u 一个符号数,%x 一个十六进制数
mysql_query("set charaset set utf-8");
$message=@$_POST["message"];
$shanchu=@$_POST["shanchu"];
$top_title="PHP基础练习";
$con=mysql_connect("localhost","root","");
//连接数据库
mysql_set_charset('utf-8',$con);
mysql_select_db("dbl",$con);
//定义数据库命令查询
$sql="select `message` ,`time`,`id` from message order by id desc limit 0,30";
//执行数据库查询
$rs=mysql_query($sql,$con);
$time=date('Y-m-d h:i:s',time());
//获取条数
$num_rows=mysql_num_rows($rs);//mysql_num_rows返回查询记录条数
if (isset($_POST["submits"])) {
if(!$_POST["message"]==null){
$queryinsert=sprintf("insert into message (message,time) values('%s','%s')",
$_POST['message'],$time);
mysql_query($queryinsert,$con);
}
if($_POST["message"]==null){
echo "";
}
header("Location:http://localhost/table.php");
}
if(isset($_GET["ClearTd"]) && intval($_GET['ClearTd'])){
$querydelete="delete from message where id=".$_GET['ClearTd'];
mysql_query($querydelete,$con);
header("Location:http://localhost/table.php");
}
?>
<form method="post" action="table.php">
<textarea name="message" id="message"></textarea>
<input type="submit" name="submits">
</form>
<ul>
<?php while($row=mysql_fetch_array($rs,MYSQL_ASSOC))
{
?>
<li>
<?php foreach($row as $tiao){
echo $tiao;
}?>
<a name="ClearTd" href="?ClearTd=<?php echo $row['id'];?>">删除</a>
</li>
<?php } ?>
</ul>
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
更新日志
- 群星《完美的她 影视原声带》[FLAC/分轨][141.05MB]
- 山风点伙.1997-深藏不露【立得】【WAV+CUE】
- 李幸倪.2018-First.Of.All.Live.Concert.3CD(2024环球红馆40复刻系列)【环球】【WAV+CUE】
- 李恕权.2003-回·20年全精选2CD【SONY】【WAV+CUE】
- 群星《你就在我身边 电影原声专辑》[320K/MP3][26.68MB]
- 群星《你就在我身边 电影原声专辑》[FLAC/分轨][70.27MB]
- 班得瑞原装进口《20周年精选集》1CD[APE/CUE分轨][303MB]
- 群星.2009-NOON.D.广东.2CD【新世纪】【WAV+CUE】
- 洪卓立.2012-GROWN.UP【英皇娱乐】【WAV+CUE】
- 梁静茹.2007-崇拜【相信音乐】【WAV+CUE】
- 金佩姗.1997-喜新恋旧【现代派】【WAV+CUE】
- 梁静茹.2007-崇拜【相信音乐】【WAV+CUE】
- 陈晓东.1997-在乎你感受(EP)【宝丽金】【WAV+CUE】
- 纯音入心系列纯音乐《云水禅心 - 佛曲古筝礼赞1-2》1CD[MP3][190MB]
- 纯音入心系列纯音乐《精心传神-古筝》1CD[MP3][363.1MB]