發(fā)表日期:2013.10.30 訪問人數(shù):1192
成都馳創(chuàng)數(shù)碼—成品網(wǎng)站快速搭建發(fā)布網(wǎng)站非常方便,但在開通后,聯(lián)系方式如果很多頁面都有,在排版模式下每一個頁面修改,耗時不說,可能還會存在大量遺漏沒有修改成功,下面方式可以快速批量修改聯(lián)系方式。成都網(wǎng)站建設(shè)方面的專家提醒大家:因操作直接操作數(shù)據(jù)庫且操作不可逆,請先備份數(shù)據(jù)庫數(shù)據(jù),然后再做以下操作!
1.登錄空間ftp,在wwwroot下建立replace.php
2,編輯這個文件輸入一下內(nèi)容:
<?php
/**
date:2013-05-12
function:批量替換數(shù)據(jù)庫中的聯(lián)系方式
**/
header("content-Type: text/html; charset=utf-8");
include_once("config.inc.php");
if(isset($_GET["act"]) && $_GET["act"] == "del" ){ //刪除測試文件
$filename=basename($_SERVER['PHP_SELF']);
@unlink($filename);
exit('Error:File Not Found!');
}
if(isset($_POST["submit"])){
$host=$dbHost;
$user=$dbUser; //數(shù)據(jù)庫用戶名
$passwd=$dbPass; //密碼
$db=$dbName; //數(shù)據(jù)庫名稱
$txt=$_POST["txt"]; //源字符串
$plustitle=$_POST["plustitle"]; //目標(biāo)字符串
$plusname=$_POST["plusname"]; //目標(biāo)字符串
$tables=$TablePre._base_plus;
$link= mysql_connect($host,$user,$passwd) or die('Could not connect: '.mysql_error() );
mysql_select_db( $db,$link ) or die ('can\'t use'. $db . mysql_error());
mysql_query ('SET NAMES utf8');
$sql1="UPDATE `$tables` SET text='$txt' where title='$plustitle' and pluslable='$plusname'";
if(mysql_query($sql1))
echo "<font color=red>替換成功!<br></font>";
else
echo "替換失敗:".mysql_error()."<br>";
mysql_close($link);
}
?>
<form method="post" action="">
<?
echo "數(shù)據(jù)庫地址: ".$dbHost ;
echo "<br/>數(shù)據(jù)庫名: ".$dbName;
echo "<br/>數(shù)據(jù)庫用戶名: ".$dbUser;
echo "<br/>數(shù)據(jù)庫密碼: ".$dbPass;
echo "<br/>表前綴: ".$TablePre;
?>
<br/>
插件標(biāo)題:<input name="plustitle" value="聯(lián)系我們" type="txt"><br/>
插件名:<input name="plusname" value="modText" type="txt"><br/>
替換內(nèi)容:<textarea name="txt" cols="50" rows="10" warp="virtual"></textarea> <br/>
<input type="submit" name="submit" value="開始替換"><br/><br/>
<font color=red >操作不可逆,請先備份數(shù)據(jù)庫后再使用</font><br/>
<a href='?act=del'>刪除測試文件</a>
</form>
保存上傳到空間
3.訪問這個http://您的域名/replace.php
按照提示完成批量替換,即可替換插件中為"modText"為聯(lián)系方式的內(nèi)容,個別頁面可能沒有修改 參照第四步修改
4.訪問http://您的域名/admin.php,登錄后,點擊"網(wǎng)頁">>"網(wǎng)頁管理">>找到聯(lián)系方式,點擊后面的修改按鈕,完成相應(yīng)修改。
5.確認(rèn)修改完成后,切記刪除剛才建立的"replace.php".以免被他人知曉,破壞網(wǎng)站正常顯示
成都網(wǎng)站建設(shè)資料請點擊【成都網(wǎng)站建設(shè)公司介紹】
成都網(wǎng)站設(shè)計案例請點擊【成都網(wǎng)站設(shè)計案例】
免費咨詢