php配合jquery實現增刪操作具體執行個體_PHP教程

來源:互聯網
上載者:User
後台使用php,前台引用jquery,實現增刪操作,代碼如下:

複製代碼 代碼如下:

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");
}
?>


    {
    ?>

  • echo $tiao;
    }?>
    ">刪除



http://www.bkjia.com/PHPjc/621690.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/621690.htmlTechArticle後台使用php,前台引用jquery,實現增刪操作,代碼如下: 複製代碼 代碼如下: script type="text/javascript" src="jquery-1.10.2.min.js"/script ?php header("...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.