|
 |
|
สอบถามเกี่ยวกับ การแจ้งเตือน ด้วยเสียง+popup เมื่อมีการอัพเดทฐานข้อมูลเข้ามา คืออยากรู้ Code จริงๆ ครับ |
|
 |
|
|
 |
 |
|
สืบเนื่องจากกระทู้นี้่อะครับ
ผมอ่านแล้วลองไปแก้ดูทำดูแล้ว ไม่เป็นผลสำเร็จเลยครับ
https://www.thaicreate.com/php/forum/029168.html
https://www.thaicreate.com/php/forum/029133.html
ส่วนอันนี้ลองเอาของคุณ Weerachai Nukitram
มาแก้โน้นนี่นั่น จนเละก็ยังไม่ได้ ครับ
( อันนี้เอาโค๊ตเริ่มต้นของเขามาให้ดู ) ส่วนโค๊ตที่ผมเขียน ลบไปแล้วครับเพราะไม่ประสปผลครับ 3 วันแล้วครับ
AjaxPHPRealtime1.php
Code (PHP)
<?php
/*** By Weerachai Nukitram ***/
/*** http://www.ThaiCreate.Com ***/
?>
<html>
<head>
<title>ThaiCreate.Com Ajax Tutorial</title>
</head>
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(Sort) {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = 'AjaxPHPRealtime2.php';
var pmeters = 'mySort='+Sort;
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
}
}
}
</script>
<body Onload="bodyOnload();">
<h1>My Customer</h1>
<form name="frmMain" action="" method="post">
<script language="JavaScript">
function bodyOnload()
{
doCallAjax('CustomerID')
setTimeout("doLoop();",2000);
}
function doLoop()
{
bodyOnload();
}
function alertWelcome()
{
bodyOnload();
}
</script>
<span id="mySpan"></span>
</body>
</html>
AjaxPHPRealtime2.php
Code (PHP)
<?php
/*** By Weerachai Nukitram ***/
/*** http://www.ThaiCreate.Com ***/
echo "Load Time : ".date("Y-m-d H:i:s");
$strSort = $_POST["mySort"];
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("alest");
$strSQL = "SELECT * FROM customer ORDER BY $strSort ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center"><a href="JavaScript:doCallAjax('CustomerID')">CustomerID</a></div></th>
<th width="98"> <div align="center"><a href="JavaScript:doCallAjax('Name')">Name</a> </div></th>
<th width="198"> <div align="center"><a href="JavaScript:doCallAjax('Email')">Email</a> </div></th>
<th width="97"> <div align="center"><a href="JavaScript:doCallAjax('CountryCode')">CountryCode</a> </div></th>
<th width="59"> <div align="center"><a href="JavaScript:doCallAjax('Budget')">Budget</a> </div></th>
<th width="71"> <div align="center"><a href="JavaScript:doCallAjax('Used')">Used</a> </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><?=$objResult["CustomerID"];?></div></td>
<td><?=$objResult["Name"];?></td>
<td><?=$objResult["Email"];?></td>
<td><div align="center"><?=$objResult["CountryCode"];?></div></td>
<td align="right"><?=$objResult["Budget"];?></td>
<td align="right"><?=$objResult["Used"];?></td>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>
Tag : PHP, MySQL, JavaScript, Ajax, Web Service

|
ประวัติการแก้ไข 2014-06-21 13:36:59
|
 |
 |
 |
 |
Date :
2014-06-21 13:33:56 |
By :
lovemusic |
View :
3154 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ แต่ว่า ...
อันนี้ก็ลองไปแล้วครับ
แต่เหมือน chrome เวอร์ชั่นใหม่ มันใช้ไม่ได้แล้วครับ พอหาข้อมูลดูก็ ไม่มีผู้พัฒนาแล้วอ่ะครับ
|
 |
 |
 |
 |
Date :
2014-06-21 16:24:52 |
By :
lovemusic |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับผม
|
 |
 |
 |
 |
Date :
2014-06-21 17:06:56 |
By :
lovemusic |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|