婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁(yè) > 知識(shí)庫(kù) > PHP+Ajax實(shí)現(xiàn)的博客文章添加類別功能示例

PHP+Ajax實(shí)現(xiàn)的博客文章添加類別功能示例

熱門(mén)標(biāo)簽:四川保險(xiǎn)智能外呼系統(tǒng)供應(yīng)商 長(zhǎng)沙做地圖標(biāo)注公司 房產(chǎn)中介用的是什么外呼系統(tǒng) 寧波外呼營(yíng)銷(xiāo)系統(tǒng) 地圖標(biāo)注專員怎么樣 電話機(jī)器人銷(xiāo)售主要負(fù)責(zé)什么 上海做外呼線路的通信公司 遼寧ai電銷(xiāo)機(jī)器人價(jià)格 福建銀行智能外呼系統(tǒng)價(jià)格

本文實(shí)例講述了PHP+Ajax實(shí)現(xiàn)的博客文章添加類別功能。分享給大家供大家參考,具體如下:

一. 代碼

fun.js

function saveType(typename, username){
  if(typename==''){   //判斷博客類別是否為空
    alert('請(qǐng)輸入類別名稱!');
  }else if(username==''){   //判斷用戶名是否為空
    alert('請(qǐng)輸入用戶名!');
  }else{
    var xmlObj;   //定義XMLHttpRequest對(duì)象
    var urlData = "typename="+typename+"username="+username;    //指定要發(fā)送的數(shù)據(jù)
    if(window.ActiveXObject){   //判斷瀏覽器是否支持ActiveXObject組件,如支持則通過(guò)ActiveXObject方式創(chuàng)建XMLHttpRequest對(duì)象
      xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
    }else if(window.XMLHttpRequest){   //如果瀏覽器不支持ActiveXObject組件,則使用XMLHttpRequest組件創(chuàng)建XMLHttpRequest對(duì)象
      xmlObj = new XMLHttpRequest();
    }
    xmlObj.onreadystatechange = callBackFun;   //指定回調(diào)函數(shù)
    xmlObj.open("POST", "saveType.php", true);   //指定提交方法和頁(yè)面
    xmlObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");   //指定發(fā)送數(shù)據(jù)庫(kù)類型
    xmlObj.send(urlData);   //指定發(fā)送的數(shù)據(jù)
    function callBackFun(){   //定義回調(diào)函數(shù)
      if(xmlObj.readyState == 4  xmlObj.status == 200){   //如果服務(wù)器端返回內(nèi)容并無(wú)錯(cuò)誤發(fā)生
        if(xmlObj.responseText == 'y'){  //判斷保存是否成功,并給出提示
          alert('類別添加成功!');
        }else{
          alert('類別添加失敗!');
        }
      }
    }
  }
}

conn.php

?php
$host = '127.0.0.1';
$userName = 'root';
$password = 'root';
$connID = mysql_connect($host, $userName, $password);
mysql_select_db('db_database27', $connID);
mysql_query('set names gbk');
?>

index.php

?php
require_once 'conn.php';
?>
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
html xmlns="http://www.w3.org/1999/xhtml">
head>
meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
title>添加類別/title>
link rel="stylesheet" type="text/css" href="css/style.css" rel="external nofollow" rel="external nofollow" />
/head>
script language="javascript" src="js/fun.js">/script>
body>
table border="0" align="center" cellpadding="0" cellspacing="0">
 tr>
  td>img src="images/banner.gif" width="608" height="109" />/td>
 /tr>
/table>
table width="200" height="7" border="0" align="center" cellpadding="0" cellspacing="0">
 tr>
  td>/td>
 /tr>
/table>
table width="608" height="200" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#7ED227">
 tr>
  td width="150" bgcolor="#F6FEFE" valign="top">
  table width="150" border="0" cellpadding="0" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#D6FEFE">
   ?php
     $sql = mysql_query("select typename,username from tb_type order by addtime desc", $connID);
     $result = mysql_fetch_array($sql);
     if ($result){
       do{
   ?>
   tr>
    td bgcolor="#A6E617" height="20">div align="center">a href="#" rel="external nofollow" rel="external nofollow" class="a1">?= $result['typename']?>/a>/div>/td>
   /tr>
   tr>
    td bgcolor="#F2F2F2" height="12">div align="left">發(fā)布人:
     ?= $result['username']?>
     /a>/div>/td>
   /tr>
   ?php
       }while($result = mysql_fetch_array($sql));
     }else{
   ?>
   tr>
    td bgcolor="#A6E617" height="20">暫無(wú)文章類別/td>
   /tr>
   ?php
     }
   ?>
/table>
  /td>
  td width="455" bgcolor="#FFFFFF" style="padding-left:30px; line-height:25px">
  請(qǐng)輸入博客類別:br />
  nbsp;nbsp;nbsp;nbsp;input type="text" name="typename" size="30" id="typename" />br />br/>
  發(fā)布人:br />
  nbsp;nbsp;nbsp;nbsp;input type="text" name="username" size="30" id="username" />br />br/>
  input type="button" value="保存" onclick="saveType(typename.value, username.value)" />
  /td>
 /tr>
/table>
table width="200" height="7" border="0" align="center" cellpadding="0" cellspacing="0">
 tr>
  td>/td>
 /tr>
/table>
table width="608" height="70" border="0" align="center" cellpadding="0" cellspacing="0">
 tr>
  td background="images/bottom.gif">div align="center">
   DIV align="center">『博客』 版權(quán)所有 a  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="a1">吉林省**科技有限公司/a>!  未經(jīng)授權(quán)禁止復(fù)制或建立鏡像!BR>
     BR>Copyright copy; a  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="a1">www.mingri***.com/a> All Rights Reserved!BR>
   /DIV>
  /div>/td>
 /tr>
/table>
/body>
/html>

saveType.php

?php
require_once 'conn.php';
?>
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
html xmlns="http://www.w3.org/1999/xhtml">
head>
meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
title>添加類別/title>
link rel="stylesheet" type="text/css" href="css/style.css" rel="external nofollow" rel="external nofollow" />
/head>
script language="javascript" src="js/fun.js">/script>
body>
table border="0" align="center" cellpadding="0" cellspacing="0">
 tr>
  td>img src="images/banner.gif" width="608" height="109" />/td>
 /tr>
/table>
table width="200" height="7" border="0" align="center" cellpadding="0" cellspacing="0">
 tr>
  td>/td>
 /tr>
/table>
table width="608" height="200" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#7ED227">
 tr>
  td width="150" bgcolor="#F6FEFE" valign="top">
  table width="150" border="0" cellpadding="0" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#D6FEFE">
   ?php
     $sql = mysql_query("select typename,username from tb_type order by addtime desc", $connID);
     $result = mysql_fetch_array($sql);
     if ($result){
       do{
   ?>
   tr>
    td bgcolor="#A6E617" height="20">div align="center">a href="#" rel="external nofollow" rel="external nofollow" class="a1">?= $result['typename']?>/a>/div>/td>
   /tr>
   tr>
    td bgcolor="#F2F2F2" height="12">div align="left">發(fā)布人:
     ?= $result['username']?>
     /a>/div>/td>
   /tr>
   ?php
       }while($result = mysql_fetch_array($sql));
     }else{
   ?>
   tr>
    td bgcolor="#A6E617" height="20">暫無(wú)文章類別/td>
   /tr>
   ?php
     }
   ?>
/table>
  /td>
  td width="455" bgcolor="#FFFFFF" style="padding-left:30px; line-height:25px">
  請(qǐng)輸入博客類別:br />
  nbsp;nbsp;nbsp;nbsp;input type="text" name="typename" size="30" id="typename" />br />br/>
  發(fā)布人:br />
  nbsp;nbsp;nbsp;nbsp;input type="text" name="username" size="30" id="username" />br />br/>
  input type="button" value="保存" onclick="saveType(typename.value, username.value)" />
  /td>
 /tr>
/table>
table width="200" height="7" border="0" align="center" cellpadding="0" cellspacing="0">
 tr>
  td>/td>
 /tr>
/table>
table width="608" height="70" border="0" align="center" cellpadding="0" cellspacing="0">
 tr>
  td background="images/bottom.gif">div align="center">
   DIV align="center">『博客』 版權(quán)所有 a  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="a1">吉林省**科技有限公司/a>!  未經(jīng)授權(quán)禁止復(fù)制或建立鏡像!BR>
     BR>Copyright copy; a  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="a1">www.mingri***.com/a> All Rights Reserved!BR>
   /DIV>
  /div>/td>
 /tr>
/table>
/body>
/html>

二. 運(yùn)行結(jié)果

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《PHP+ajax技巧與應(yīng)用小結(jié)》、《PHP網(wǎng)絡(luò)編程技巧總結(jié)》、《PHP基本語(yǔ)法入門(mén)教程》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門(mén)教程》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫(kù)操作入門(mén)教程》及《php常見(jiàn)數(shù)據(jù)庫(kù)操作技巧匯總》

希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。

您可能感興趣的文章:
  • php 三級(jí)聯(lián)動(dòng)菜單
  • php+mysql實(shí)現(xiàn)的二級(jí)聯(lián)動(dòng)菜單效果詳解
  • PHP+JS三級(jí)菜單聯(lián)動(dòng)菜單實(shí)現(xiàn)方法
  • thinkPHP實(shí)現(xiàn)的聯(lián)動(dòng)菜單功能詳解
  • thinkPHP基于ajax實(shí)現(xiàn)的菜單與分頁(yè)示例
  • ThinkPHP使用心得分享-ThinkPHP + Ajax 實(shí)現(xiàn)2級(jí)聯(lián)動(dòng)下拉菜單
  • 落伍首發(fā) php+mysql 采用ajax技術(shù)的 省 市 地 3級(jí)聯(lián)動(dòng)無(wú)刷新菜單 源碼
  • PHP+ajax實(shí)現(xiàn)獲取新聞數(shù)據(jù)簡(jiǎn)單示例
  • php+ajax實(shí)現(xiàn)無(wú)刷新文件上傳功能(ajaxuploadfile)
  • Ajax中的JSON格式與php傳輸過(guò)程全面解析
  • PHP+ajax實(shí)現(xiàn)二級(jí)聯(lián)動(dòng)菜單功能示例

標(biāo)簽:常德 澳門(mén) 工商登記 佛山 宿遷 深圳 延安 宜春

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《PHP+Ajax實(shí)現(xiàn)的博客文章添加類別功能示例》,本文關(guān)鍵詞  PHP+Ajax,實(shí)現(xiàn),的,博客,文章,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《PHP+Ajax實(shí)現(xiàn)的博客文章添加類別功能示例》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于PHP+Ajax實(shí)現(xiàn)的博客文章添加類別功能示例的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 民县| 綦江县| 高安市| 灵丘县| 左云县| 绥宁县| 喀喇沁旗| 凌源市| 沙河市| 天柱县| 繁昌县| 泾源县| 富源县| 玛曲县| 伊金霍洛旗| 东乡族自治县| 抚州市| 曲阜市| 伊宁县| 上杭县| 长治县| 井冈山市| 淮南市| 昌平区| 定陶县| 五家渠市| 犍为县| 磐石市| 新干县| 五大连池市| 阳东县| 洱源县| 开阳县| 南华县| 宽城| 宜兴市| 高雄县| 伊宁县| 邳州市| 米脂县| 济阳县|