1、數(shù)據(jù)庫(kù)本身都帶有replace函數(shù)可以直接替換,不同的數(shù)據(jù)庫(kù)的replace替換語(yǔ)法不同,可以根據(jù)你的實(shí)際情況確定使用。這樣可以直接使用SQL語(yǔ)句替換就可以了,在PHP中執(zhí)行這個(gè)SQL。
創(chuàng)新互聯(lián)公司專注于企業(yè)成都全網(wǎng)營(yíng)銷推廣、網(wǎng)站重做改版、哈爾濱網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、H5高端網(wǎng)站建設(shè)、成都做商城網(wǎng)站、集團(tuán)公司官網(wǎng)建設(shè)、外貿(mào)網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁(yè)設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為哈爾濱等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。
2、直接在PHP使用查詢語(yǔ)句,查詢出需要替換的數(shù)據(jù)表數(shù)據(jù),之后通過(guò)PHP的str_replace方法進(jìn)行替換,將替換后的結(jié)果在創(chuàng)建一個(gè)Update的SQL語(yǔ)句,在PHP中再次執(zhí)行Update語(yǔ)句,也可以實(shí)現(xiàn)更新。
根據(jù)自己的實(shí)際情況確定,選哪種都可以。
希望對(duì)你有幫助。
首先,你要一個(gè)form 表單,把數(shù)據(jù)提交到php文件,
php文件再給收到的數(shù)據(jù)補(bǔ)全,再寫入數(shù)據(jù)庫(kù)。
form表單頁(yè):
form action="age.php" method="POST"
年齡:input tyle="text" name="weixin" /
/form
php接收并寫入數(shù)據(jù)庫(kù)頁(yè):
$age= "我的年齡:”.$_POST["weixin"].“ 歲“;
然后是連接并發(fā)送到數(shù)據(jù)庫(kù)。。。。。
獲取ppq數(shù)據(jù)庫(kù)的所有表名的代碼:
?php
$server='localhost';
$user='root';
$pass='12345';
$dbname='ppq';
$conn=mysql_connect($server,$user,$pass);
if(!$conn)
die("數(shù)據(jù)庫(kù)系統(tǒng)連接失??!");
$result=mysql_list_tables($dbname);
if(!$result)
die("數(shù)據(jù)庫(kù)連接失敗!");
while($row=mysql_fetch_row($result))
{
echo
$row[0]."
";
}
mysql_free_result($result);
?
mysql_list_tables
(PHP
3,
PHP
4
,
PHP
5)
mysql_list_tables
--
列出
MySQL
數(shù)據(jù)庫(kù)中的表
說(shuō)明
resource
mysql_list_tables
(
string
database
[,
resource
link_identifier])
mysql_list_tables()
接受一個(gè)數(shù)據(jù)庫(kù)名并返回和
mysql_query()
函數(shù)很相似的一個(gè)結(jié)果指針。用
mysql_fetch_array()或者用mysql_fetch_row()來(lái)獲得一個(gè)數(shù)組,數(shù)組的第0列就是數(shù)組名,當(dāng)獲取不到時(shí)
mysql_fetch_array()或者用mysql_fetch_row()返回
FALSE。
試編寫代碼如下:
?php
//從數(shù)據(jù)庫(kù)根據(jù)?id?獲取顏色
function?getColor($db,?$id)
{
if?($result?=?$db-query("SELECT?*?FROM?color?where?id='"?.?$id?.?"'"))
{
$row?=?$result-fetch_assoc();
return?$row['color'];
}
return?'#000000';
}
$mysqli?=?new?mysqli("localhost",?"test",?"test",?"room");
if?($mysqli-connect_error)?{
printf("數(shù)據(jù)庫(kù)連接錯(cuò)誤:?%s\n",?mysqli_connect_error());
exit();
}
?
table?border="1"?cellspacing="0"
tr
td?bgcolor="?php?echo?getColor($mysqli,'1')?"1/td
/tr
tr
td?bgcolor="?php?echo?getColor($mysqli,'2')?"2/td
/tr
tr
td?bgcolor="?php?echo?getColor($mysqli,'3')?"3/td
/tr
/table
?php
$mysqli-close();
?