加入客源網
每天多接2個客戶,做生意就是這麼簡單
搬家公司居家清潔請找
易祺清潔公司

首頁  •  j2h 論壇 • 程式設計討論     • 

[JQuery] Insert and Load Record using j

房東:小鋒
發表時間:2011-05-08




inserting.php

Contains of javascript and HTML code.


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/

libs/jquery/1.3.0/jquery.min.js
">

</script>

<script type="text/javascript" >

$(function() {

$(".comment_button").click(function() {



var test = $("#content").val();

var dataString = 'content='+ test;



if(test=='')

{

alert("Please Enter Some Text");

}

else

{

$("#flash").show();

$("#flash").fadeIn(400).html('<img src="ajax-loader.gif" align="absmiddle"> <span class="loading">Loading Comment...</span>');



$.ajax({

type: "POST",

url: "demo_insert.php",

data: dataString,

cache: false,

success: function(html){

$("#display").after(html);

document.getElementById('content').value='';

document.getElementById('content').focus();

$("#flash").hide();

}

});

} return false;

});

});

</script>

// HTML code

 

<div>

<form method="post" name="form" action="">

 

<h3>What are you doing?</h3>

<textarea cols="30" rows="2" name="content" id="content" maxlength="145" >

</textarea><br />

<input type="submit" value="Update" name="submit" class="comment_button"/>

 

</form>

</div>

<div id="flash"></div>

<div id="display"></div>

 









demo_insert.php

PHP Code display recently inserted record from the database.


<?php

include('db.php');

if(isSet($_POST['content']))

{

$content=$_POST['content'];

mysql_query("insert into messages(msg) values ('$content')");

$sql_in= mysql_query("SELECT msg,msg_id FROM messages order by msg_id desc");

$r=mysql_fetch_array($sql_in);

}

?>

<b><?php echo $r['msg']; ?></b>










  • 贊助網站       

    廣利不動產-新板特區指名度最高、值得您信賴的好房仲
    您的托付,廣利用心為您服務
    廣利不動產-板橋在地生根最實在--新板特區指名度最高、值得您信賴的好房仲
    完整房訊,房屋、店面熱門精選物件,廣利不動產 優質仲介,房屋租賃、買賣資訊透明,交易真安心!

  • 1 樓住戶:小鋒
    發表時間:2011-05-08

    http://www.9lessons.info/2009/05/insert-and-load-record-using-jquery-and.html
    http://coder1.com/articles/jquery-sortables-php-and-mysql
    http://www.9lessons.info/2009/07/delete-records-with-random-animation.html
    http://www.helloweba.com/view-blog-121.html



     共 1 人回應  選擇頁數 【第1 頁】 

    姓名:
    佈告內容:
    其他選項: