php修改sql的方法:1、連接資料庫並查詢資料;2、透過頁面addnews.html加入資料;3、透過「mysql_query("UPDATE news SET title='$title'...) 」語句修改更新資料即可。
本文操作環境:Windows7系統、PHP7.1版、DELL G3電腦
php 怎麼修改sql?
PHP Mysql 實作資料庫增刪改查
PHP和Mysql可以對資料庫進行簡單的增刪改查,本文介紹了新聞清單的後台管理。
https://github.com/caochangkui/php-mysql-test
##Mysql資料庫建立 創建一個新聞清單的資料庫: 1. 查詢資料庫1.1. 建立檔案dbconfig.php,儲存常數61bf395024acb6a782eaed079492725a 100db36a723c770d327fc0aef2ce13b1 30a2558f92eb013b60562303f10db00a a80eb7cbb6fff8b0ff70bae37074b813 b2386ffb911b14667cb8f0f91ea547a7添加新闻6e916e0f7d1e588d4f442bf645aedb2f 9c3bca370b5104690d9ef395f2c5f8d1 46d5fe1c7617e3914f214aaf043f4ccf form{ margin: 20px; } 531ac245ce3e4fe3d50054a55f265927 6c04bd5ca3fcae76e30b72ad730ca86d f183c3a2beadc0e1ede3a6cb9cfa78ef 2e1cf0710519d5598b1f0f14c36ba674标题:8c1ecd4bb896b2264e0711597d40766c9d4b1097ff533c07e208dfc2f023aaa5 2e1cf0710519d5598b1f0f14c36ba674关键字:8c1ecd4bb896b2264e0711597d40766c870e094f5f98782e56976fd61e1c399d 2e1cf0710519d5598b1f0f14c36ba674作者:8c1ecd4bb896b2264e0711597d40766c86a30740364efcfa938a43188642a31e 2e1cf0710519d5598b1f0f14c36ba674发布时间:8c1ecd4bb896b2264e0711597d40766cefcfc4015012ccd6635920d075859ba2 2e1cf0710519d5598b1f0f14c36ba674内容:8c1ecd4bb896b2264e0711597d40766c62c035209029b741eecb010365badbd5 10c88813b1d79313d0132c5ec3999828 f5a47148e367a6035fd7a2faa965022e 36cc49f0c466276486e50c850b7e4956 73a6ac4ed44ffec12cee46588e518a5e
d7d88e3612e9051e7f7890f626832cae 100db36a723c770d327fc0aef2ce13b1 93f0f5c25f18dab9d176bd4f6de5d30e a80eb7cbb6fff8b0ff70bae37074b813 b2386ffb911b14667cb8f0f91ea547a7修改新闻6e916e0f7d1e588d4f442bf645aedb2f 9c3bca370b5104690d9ef395f2c5f8d1 6c04bd5ca3fcae76e30b72ad730ca86d bec4dc7c01d8d35dfeea446fb873ae74 5b6440b152f1717ad467bfa2d9f47bcc 2e1cf0710519d5598b1f0f14c36ba674新闻ID: 8c1ecd4bb896b2264e0711597d40766c4be8a3545d89f1aff7be524582b95ff1"> 2e1cf0710519d5598b1f0f14c36ba674标题:8c1ecd4bb896b2264e0711597d40766c8c02f2ad7f2e96677eb4b5230248f28f"> 2e1cf0710519d5598b1f0f14c36ba674关键字:8c1ecd4bb896b2264e0711597d40766c2b3b94264a65f5319c5c21839ecfc82f"> 2e1cf0710519d5598b1f0f14c36ba674作者:8c1ecd4bb896b2264e0711597d40766c2af1655cc74b47cd711ef0965ca22e7e"> 2e1cf0710519d5598b1f0f14c36ba674发布时间:8c1ecd4bb896b2264e0711597d40766c32cc377d8d08043eec536521d39a9117"> 2e1cf0710519d5598b1f0f14c36ba674内容:8c1ecd4bb896b2264e0711597d40766ca2d9269dfb9a6f2cb53af92126c9c99d"> 10c88813b1d79313d0132c5ec3999828 f5a47148e367a6035fd7a2faa965022e 36cc49f0c466276486e50c850b7e4956 73a6ac4ed44ffec12cee46588e518a5e
PHP影片教學》】
<?php // 处理编辑操作的页面 require "dbconfig.php"; // 连接mysql $link = @mysql_connect(HOST,USER,PASS) or die("提示:数据库连接失败!"); // 选择数据库 mysql_select_db(DBNAME,$link); // 编码设置 mysql_set_charset('utf8',$link); // 获取修改的新闻 $id = $_POST['id']; $title = $_POST['title']; $keywords = $_POST['keywords']; $autor = $_POST['autor']; $addtime = $_POST['addtime']; $content = $_POST['content']; // 更新数据 mysql_query("UPDATE news SET title='$title',keywords='$keywords',autor='$autor',addtime='$addtime',content='$content' WHERE id=$id",$link) or die('修改数据出错:'.mysql_error()); header("Location:demo.php");
以上是php 怎麼修改sql的詳細內容。更多資訊請關注PHP中文網其他相關文章!