后台使用php,前台引用jquery,实现增删操作,代码如下:
<span 1</span> <span><script type="text/javascript" src="http://keleyi.com/keleyi/pmedia/jquery/jquery-1.10.2.min.js"></script></span> <span 2</span> <?<span php </span><span 3</span> <span header</span>("Content-type: text/html; charset=utf-8"<span ); </span><span 4</span> <span //</span><span mysql_connect 建立连接,mysql_close($link)关闭非永久连接,mysql_pconnect 建立永久连接 </span><span 5</span> <span //mysql_error返回mysql函数错误信息,mysql_errno返回mysql函数错误号码 </span><span 6</span> <span //mysql_set_charset 设置用户端字符集,mysql_select_db 选择连接数据库 </span><span 7</span> <span //mysql_query 执行查询,mysql_num_rows返回查询记录条数 </span><span 8</span> <span //mysql_affected_rows返回受影响的记录条数,mysql_free_result 释放结果集内存 </span><span 9</span> <span //mysql_fetch_row 返回列举阵列记录,mysql_fetch_assoc 返回关联阵列记录 </span><span 10</span> <span //mysql_fetch_array 返回关联阵列或数字阵列记录,mysql_fetch_object 返回物件形式记录 </span><span 11</span> <span //mysql_fetch_result 取得结果集资料 </span><span 12</span> <span //%s 字符串,%c 一个ASCII字符,%d 一个整数,%u 一个符号数,%x 一个十六进制数 </span> <span 13</span> <span mysql_query</span>("set charaset set utf-8"<span ); </span><span 14</span> <span $message</span>=@<span $_POST</span>["message"<span ]; </span><span 15</span> <span $shanchu</span>=@<span $_POST</span>["shanchu"<span ]; </span><span 16</span> <span $top_title</span>="PHP基础练习"<span ; </span><span 17</span> <span $con</span>=<span mysql_connect</span>("localhost","root",""<span ); </span><span 18</span> <span //</span><span 连接数据库 </span> <span 19</span> mysql_set_charset('utf-8',<span $con</span><span ); </span><span 20</span> <span mysql_select_db</span>("dbl",<span $con</span><span ); </span><span 21</span> <span //</span><span 定义数据库命令查询 </span> <span 22</span> <span $sql</span>="select `message` ,`time`,`id` from message order by id desc limit 0,30"<span ; </span><span 23</span> <span //</span><span 执行数据库查询 http://www.cnblogs.com/roucheng/</span> <span 24</span> <span $rs</span>=<span mysql_query</span>(<span $sql</span>,<span $con</span><span ); </span><span 25</span> <span $time</span>=<span date</span>('Y-m-d h:i:s',<span time</span><span ()); </span><span 26</span> <span //</span><span 获取条数 </span> <span 27</span> <span 28</span> <span $num_rows</span>=<span mysql_num_rows</span>(<span $rs</span>);<span //</span><span mysql_num_rows返回查询记录条数 </span> <span 29</span> <span if</span> (<span isset</span>(<span $_POST</span>["submits"<span ])) { </span><span 30</span> <span if</span>(!<span $_POST</span>["message"]==<span null</span><span ){ </span><span 31</span> <span $queryinsert</span>=<span sprintf</span>("insert into message (message,time) values('%s','%s')", <span 32</span> <span $_POST</span>['message'],<span $time</span><span ); </span><span 33</span> <span mysql_query</span>(<span $queryinsert</span>,<span $con</span><span ); </span><span 34</span> <span } </span><span 35</span> <span if</span>(<span $_POST</span>["message"]==<span null</span><span ){ </span><span 36</span> <span echo</span> ""<span ; </span><span 37</span> <span } </span><span 38</span> <span header</span>("Location:http://localhost/table.php"<span ); </span><span 39</span> <span } </span><span 40</span> <span 41</span> <span if</span>(<span isset</span>(<span $_GET</span>["ClearTd"]) && <span intval</span>(<span $_GET</span>['ClearTd'<span ])){ </span><span 42</span> <span $querydelete</span>="delete from message where id=".<span $_GET</span>['ClearTd'<span ]; </span><span 43</span> <span mysql_query</span>(<span $querydelete</span>,<span $con</span><span ); </span><span 44</span> <span header</span>("Location:http://localhost/table.php"<span ); </span><span 45</span> <span } </span><span 46</span> ?> <span 47</span> <span 48</span> <form method="post" action="table.php"> <span 49</span> <textarea name="message" id="message"></textarea> <span 50</span> <input type="submit" name="submits"> <span 51</span> </form> <span 52</span> <span 53</span> <ul> <span 54</span> <?php <span while</span>(<span $row</span>=<span mysql_fetch_array</span>(<span $rs</span>,<span MYSQL_ASSOC)) </span><span 55</span> <span { </span><span 56</span> ?> <span 57</span> <li> <span 58</span> <?php <span foreach</span>(<span $row</span> <span as</span> <span $tiao</span><span ){ </span><span 59</span> <span echo</span> <span $tiao</span><span ; </span><span 60</span> }?> <span 61</span> <a name="ClearTd" href="?ClearTd=<?php echo <span $row</span>['id'];?>">删除</a> <span 62</span> </li> <span 63</span> <?php } ?> <span 64</span> </ul>

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\ \;||\xc2\xa0)/","其他字符",$str)”语句。

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download
The most popular open source editor

Notepad++7.3.1
Easy-to-use and free code editor
