当前位置: 编程技术>php
本页文章导读:
▪利用php来自动调用不同服务器上的flash
近期,学校校庆,做了一个flash动画的网站,但体积比较庞大。如果上传到学校的服务器,从公众信息网访问就比较慢,而放到教育网外从校园网访问就比较不流畅,还好,我们有php,解决了.........
▪如何做到多筆資料的同步
一次叫出多筆資料,然後在同一個網頁中「逐一」「分別」做不同的處理,最後「同時」對資料庫 update or insert 。每一筆資料所收到的update 、insert數據並不相同! ============================ .........
▪社区(php&&mysql)二
function sdatetime($str){ $str=ereg_replace("-","/",$str); $str=substr($str,5,strlen($str)-8); return $str; } function reAnum($sid){ //羆莱絞计 $DROOT=getenv('DOCUMENT_ROOT'); include("sql.php3"); .........
[1]利用php来自动调用不同服务器上的flash
来源: 互联网 发布时间: 2013-11-30
近期,学校校庆,做了一个flash动画的网站,但体积比较庞大。如果上传到学校的服务器,从公众信息网访问就比较慢,而放到教育网外从校园网访问就比较不流畅,还好,我们有php,解决了这一问题!
代码如下:
<html>
<head>
<title>庆校庆</title>
</head>
<body bgcolor="#f2d560" topmargin=0 leftmargin=0>
<?php
$remote_addr=getenv("REMOTE_ADDR");
$testip="202.117.6";
$realip=substr($remote_addr,0,9);
if($testip==$realip){
$url="http://202.117.68.12/~flyhawk/cau.swf";
$word="长大校园网";
}else{
$url="http://webnow.oso.com.cn/cau.swf";
$word="公众信息网";
}
?>
<script language="JavaScript">
function Info()
{
if (!confirm("欢迎光临长安校庆专题网"+"\n\n您的IP:<? echo $remote_addr ?>\n\n您来自<? echo $word ?>\n\n请稍候.....\n\n正在引导网页以提供最快的网络传输"+"\n\n\n请按确定进入本页浏览\n"+"\n按取消将离开本站\n"+"\n\n\n【我爱长安大学】 "))
history.go(-1);return " "
}
document.writeln(Info())</script>
</SCRIPT>
<embed src="/blog_article/</ echo $url /gt;.html" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="100%" height="98%">
</embed>
</body>
</html>
简单提示:
$remote_addr=getenv("REMOTE_ADDR"); 是获得客户机的ip.
$realip=substr($remote_addr,0,9);获得ip的前9个字节,因为我们学校的ip地址是202.117.6*.*,所以,通过判断$realip与$testip的值的不同来确定$url的值,即flash的文件位置。
本程序的演示请见:http://www.caunet.com
代码如下:
<html>
<head>
<title>庆校庆</title>
</head>
<body bgcolor="#f2d560" topmargin=0 leftmargin=0>
<?php
$remote_addr=getenv("REMOTE_ADDR");
$testip="202.117.6";
$realip=substr($remote_addr,0,9);
if($testip==$realip){
$url="http://202.117.68.12/~flyhawk/cau.swf";
$word="长大校园网";
}else{
$url="http://webnow.oso.com.cn/cau.swf";
$word="公众信息网";
}
?>
<script language="JavaScript">
function Info()
{
if (!confirm("欢迎光临长安校庆专题网"+"\n\n您的IP:<? echo $remote_addr ?>\n\n您来自<? echo $word ?>\n\n请稍候.....\n\n正在引导网页以提供最快的网络传输"+"\n\n\n请按确定进入本页浏览\n"+"\n按取消将离开本站\n"+"\n\n\n【我爱长安大学】 "))
history.go(-1);return " "
}
document.writeln(Info())</script>
</SCRIPT>
<embed src="/blog_article/</ echo $url /gt;.html" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="100%" height="98%">
</embed>
</body>
</html>
简单提示:
$remote_addr=getenv("REMOTE_ADDR"); 是获得客户机的ip.
$realip=substr($remote_addr,0,9);获得ip的前9个字节,因为我们学校的ip地址是202.117.6*.*,所以,通过判断$realip与$testip的值的不同来确定$url的值,即flash的文件位置。
本程序的演示请见:http://www.caunet.com
[2]如何做到多筆資料的同步
来源: 互联网 发布时间: 2013-11-30
一次叫出多筆資料,然後在同一個網頁中「逐一」「分別」做不同的處理,最後「同時」對資料庫 update or insert 。每一筆資料所收到的update 、insert數據並不相同! ============================
處理要點在於 _____ loop + array
1.從資料庫叫出資料:
db_query進行looping的同時,把相關欄位需要update的資料通通納入array.
依照各人需求,這些資料可以用text、checkbox、或者hidden等各種型態呈現。當然,checkbox是最常見的type.
例如,郵件處理網頁就大量使用checkbox.
2.修改後的資料回存作業
要點在count(array) + loop + db_update:
根據count的結果進行迴旋,把db_update放進去,讓loop去完成所有資料的update回存作業。
範例如下:
================================================
####1.update.php: 以loop+array取出資料以便update........
<form action="/blog_article/activate.html">
#在這裡呼叫資料庫
$query="select * from $userstable where...................
#進入loop逐一取出資料
$i=0;
while ($i < $num):
...............
$id=mysql_result($result,$i,"id");
..................
............................
#以適當的type取出必須更新的欄位,構成array ..........
echo "<td align...................
echo "<td align=middle><input type=text size=3 name=\"Cname[]\" value=\"$name\"></td></tr>";
echo "<input type=hidden name=\"Cid[]\" value=\"$id\">";
$i++;
endwhile;
======================================================
####2.activate.php:資料更新後,透過loop+array完成回存...................
.......
for ($i = 0; $i < count($Cname); $i++) {
$name = $Cname[$i];
$id= $Cid[$i];
$query = "update $userstable set name='$name' where id='$id'";
.............
處理要點在於 _____ loop + array
1.從資料庫叫出資料:
db_query進行looping的同時,把相關欄位需要update的資料通通納入array.
依照各人需求,這些資料可以用text、checkbox、或者hidden等各種型態呈現。當然,checkbox是最常見的type.
例如,郵件處理網頁就大量使用checkbox.
2.修改後的資料回存作業
要點在count(array) + loop + db_update:
根據count的結果進行迴旋,把db_update放進去,讓loop去完成所有資料的update回存作業。
範例如下:
================================================
####1.update.php: 以loop+array取出資料以便update........
<form action="/blog_article/activate.html">
#在這裡呼叫資料庫
$query="select * from $userstable where...................
#進入loop逐一取出資料
$i=0;
while ($i < $num):
...............
$id=mysql_result($result,$i,"id");
..................
............................
#以適當的type取出必須更新的欄位,構成array ..........
echo "<td align...................
echo "<td align=middle><input type=text size=3 name=\"Cname[]\" value=\"$name\"></td></tr>";
echo "<input type=hidden name=\"Cid[]\" value=\"$id\">";
$i++;
endwhile;
======================================================
####2.activate.php:資料更新後,透過loop+array完成回存...................
.......
for ($i = 0; $i < count($Cname); $i++) {
$name = $Cname[$i];
$id= $Cid[$i];
$query = "update $userstable set name='$name' where id='$id'";
.............
[3]社区(php&&mysql)二
来源: 互联网 发布时间: 2013-11-30
function sdatetime($str){
$str=ereg_replace("-","/",$str);
$str=substr($str,5,strlen($str)-8);
return $str;
}
function reAnum($sid){ //羆莱絞计
$DROOT=getenv('DOCUMENT_ROOT');
include("sql.php3");
$db=mysql_connect($sql['host'], $sql['user'] , $sql['passwd']);
$qsql="SELECT id from bbs_docs where sid='$sid'";
$rs=mysql_db_query($sql['db'],$qsql);
return mysql_num_rows($rs);
}
function pagebar($pages) {
global $pgno;
//global $pages;
global $PHP_SELF;
global $aid;
global $OPEN_LIST;
echo "<TABLE width=85% border=0 cellPadding=0 cellSpacing=1 align=center bgcolor='#6CA6CD' >";
echo "<tr><td>";
if($pgno!=0) {
$pu=$pgno-1;
echo "<a href=/blog_article/$PHP_SELF/aid/$aid/amp;pgno/$pu/gt;[]/lt;/a/gt;.html";
}
if($pgno<$pages) {
$pd=$pgno+1;
echo "<a href=/blog_article/$PHP_SELF/aid/$aid/amp;pgno/$pd/gt;[]/lt;/a/gt;.html";
}
for($i=0;$i<=$pages;$i++) {
if($pgno==$i) {
echo "<b>";
echo "[".($i+1)."]";
echo "</b>";
} else {
echo "<a href=/blog_article/$PHP_SELF/aid/$aid/amp;pgno/$i/gt;.html";
echo "[".($i+1)."]";
echo "</a>";
}
}
echo "</td>";
echo "<TD align=right>";
echo "<a href=/blog_article/$PHP_SELF/proc/view/amp;aid/$aid/gt;.html";
echo "[祇ゅ彻]";
echo "</a>";
//echo "</TD>";
//echo "<TD align=right>";
if($OPEN_LIST) {
echo "<a href=/blog_article/$PHP_SELF/proc/colloff/amp;aid/$aid/amp;pgno/$pgno/gt;.html";
echo "[ぃ甶秨杠肈]";
echo "</a>";
}else {
echo "<a href=/blog_article/$PHP_SELF/proc/collon/amp;aid/$aid/amp;/amp;pgno/$pgno/gt;.html";
echo "[甶秨杠肈]";
echo "</a>";
}
echo "</TD>";
echo "</tr></table>";
}
//===============================================================================
function openlist($sid) {
global $aid;
global $PHP_SELF;
$DROOT=getenv('DOCUMENT_ROOT');
include("sql.php3");
$db=mysql_connect($sql['host'], $sql['user'] , $sql['passwd']);
$qsql="SELECT * from bbs_docs where sid='$sid' order by wdate";
$rs=mysql_db_query($sql['db'],$qsql);
//if(mysql_num_rows($rs)==0) return;
//echo mysql_num_rows($rs);
while($row=mysql_fetch_array($rs)) {
$id=$row['id'];
$banner=$row['banner'];
$poster=$row['poster'];
$views=$row['views'];
$wdate=sdatetime($row['wdate']);
echo "<tr bgcolor='#F0F0F0'>";
echo "<td>";
echo "<a href=/blog_article/$PHP_SELF/proc/view/amp;aid/$aid/amp;sid/$sid/amp;rid/$id/gt;.html";
echo " <font color=#836FFF>$banner</font>";
echo "</a>";
//echo "banner is $banner";
echo "</td>";
echo "<td>";
echo $poster;
echo "</td>";
echo "<td >";
echo " ";
echo "</td>";
echo "<td >";
echo $views;
echo "</td>";
echo "<td >";
echo $wdate;
echo "</td>";
echo "</tr>";
}
}
//========================================================================
function area() {
global $PHP_SELF;
global $aid,$sid,$pgno;
global $OPEN_LIST;
$showitems=20;
$DROOT=getenv('DOCUMENT_ROOT');
include("sql.php3");
$db=mysql_connect($sql['host'], $sql['user'] , $sql['passwd']);
//============================================================
if(!$aid) {
$qsql="SELECT id from bbs_area";
$rs=mysql_db_query($sql['db'],$qsql);
$row=mysql_fetch_array($rs);
$aid=$row['id'];
}
if(!$sid) {
$qsql="SELECT id from bbs_subj where aid=$aid order by wdate DESC";
$rs=mysql_db_query($sql['db'],$qsql);
$row=mysql_fetch_array($rs);
$sid=$row['id'];
}
if(!$pgno) {//礚﹚计
//$pgno=0;
$items=0;
$qsql="SELECT id from bbs_subj where aid=$aid order by wdate DESC";
$rs=mysql_db_query($sql['db'],$qsql);
while($row=mysql_fetch_array($rs)){
$id=$row['id'];
if($id==$sid) break;
$items++;
}
$pgno=(INT)($items/$showitems);
}
//============================================================
$qsql="SELECT * from bbs_area where id=$aid ";
$rs=mysql_db_query($sql['db'],$qsql);
$row=mysql_fetch_array($rs);
$banner=$row['banner'];
$body=$row['body'];
$master=$row['master'];
echo "<center><font color=GREEN size=5><b>$banner</b></font></center>";
echo "<FORM name=mtab ENCTYPE=multipart/form-data METHOD=POST ACTION=$PHP_SELF?proc=search>";
echo "<TABLE width=85% border=0 cellPadding=0 cellSpacing=1 align=center >";
echo "<tr><td>";
echo "<input type='hidden' name=aid value='$aid'>";
echo "穓碝ゅ彻:";
echo "<INPUT TYPE='TEXT' NAME='key' size=25 >";
echo "<INPUT TYPE='Submit'value='琩高' >";
echo "</td></tr>";
echo "</table>";
echo "</FORM>";
$qsql="SELECT * from bbs_subj where aid=$aid order by wdate DESC";
$rs=mysql_db_query($sql['db'],$qsql);
$all=mysql_num_rows($rs); //how rows
$pages=(INT)($all/$showitems); // how pages
$pgcount=$pgno*$showitems;
if($pgcount > $all) {
$pgno=$pages-1; // Page point over all pages
$pgcount=$pgno*$showitems;
}
mysql_data_seek($rs, $pgcount);
$cnt=0;
pagebar($pages);
echo "<TABLE width=85% border=0 cellPadding=0 cellSpacing=1 align=center bgcolor='#6CA6CD'>";
echo "<tr><td>";
echo "<TABLE width=100% cellPadding=1 cellSpacing=1 bgcolor=white >";
echo "<tr bgcolor=#F1E1FF>";
echo "<th >夹肈</th>";
echo "<th>祇癬</th>";
echo "<th width=30>莱</th>";
echo "<th width=30></th>";
echo "<th width=70>ら戳</th>";
echo "</tr>";
while($row=mysql_fetch_array($rs)) {
if(++$cnt > $showitems) break;
$id=$row['id'];
$banner=$row['banner'];
$poster=$row['poster'];
$views=$row['views'];
$wdate=sdatetime($row['wdate']);
$docs=reAnum($id);
echo "<tr bgcolor='#F0F8FF'>";
echo "<td>";
echo "<a href=/blog_article/$PHP_SELF/proc/view/amp;aid/$aid/amp;sid/$id/amp;rid/$id/gt;.html";
if($sid==$id) echo "<font color=red>〈$banner</font>";
else echo $banner;
echo "</a>";
echo "</td>";
echo "<td>";
echo $poster;
echo "</td>";
echo "<td >";
echo $docs;
echo "</td>";
echo "<td >";
echo $views;
echo "</td>";
echo "<td >";
echo $wdate;
echo "</td>";
echo "</tr>";
if($OPEN_LIST) openlist($id);
}
echo "</td></tr></table>";
echo"</td></tr></table>";
pagebar($pages);
}
待续........
$str=ereg_replace("-","/",$str);
$str=substr($str,5,strlen($str)-8);
return $str;
}
function reAnum($sid){ //羆莱絞计
$DROOT=getenv('DOCUMENT_ROOT');
include("sql.php3");
$db=mysql_connect($sql['host'], $sql['user'] , $sql['passwd']);
$qsql="SELECT id from bbs_docs where sid='$sid'";
$rs=mysql_db_query($sql['db'],$qsql);
return mysql_num_rows($rs);
}
function pagebar($pages) {
global $pgno;
//global $pages;
global $PHP_SELF;
global $aid;
global $OPEN_LIST;
echo "<TABLE width=85% border=0 cellPadding=0 cellSpacing=1 align=center bgcolor='#6CA6CD' >";
echo "<tr><td>";
if($pgno!=0) {
$pu=$pgno-1;
echo "<a href=/blog_article/$PHP_SELF/aid/$aid/amp;pgno/$pu/gt;[]/lt;/a/gt;.html";
}
if($pgno<$pages) {
$pd=$pgno+1;
echo "<a href=/blog_article/$PHP_SELF/aid/$aid/amp;pgno/$pd/gt;[]/lt;/a/gt;.html";
}
for($i=0;$i<=$pages;$i++) {
if($pgno==$i) {
echo "<b>";
echo "[".($i+1)."]";
echo "</b>";
} else {
echo "<a href=/blog_article/$PHP_SELF/aid/$aid/amp;pgno/$i/gt;.html";
echo "[".($i+1)."]";
echo "</a>";
}
}
echo "</td>";
echo "<TD align=right>";
echo "<a href=/blog_article/$PHP_SELF/proc/view/amp;aid/$aid/gt;.html";
echo "[祇ゅ彻]";
echo "</a>";
//echo "</TD>";
//echo "<TD align=right>";
if($OPEN_LIST) {
echo "<a href=/blog_article/$PHP_SELF/proc/colloff/amp;aid/$aid/amp;pgno/$pgno/gt;.html";
echo "[ぃ甶秨杠肈]";
echo "</a>";
}else {
echo "<a href=/blog_article/$PHP_SELF/proc/collon/amp;aid/$aid/amp;/amp;pgno/$pgno/gt;.html";
echo "[甶秨杠肈]";
echo "</a>";
}
echo "</TD>";
echo "</tr></table>";
}
//===============================================================================
function openlist($sid) {
global $aid;
global $PHP_SELF;
$DROOT=getenv('DOCUMENT_ROOT');
include("sql.php3");
$db=mysql_connect($sql['host'], $sql['user'] , $sql['passwd']);
$qsql="SELECT * from bbs_docs where sid='$sid' order by wdate";
$rs=mysql_db_query($sql['db'],$qsql);
//if(mysql_num_rows($rs)==0) return;
//echo mysql_num_rows($rs);
while($row=mysql_fetch_array($rs)) {
$id=$row['id'];
$banner=$row['banner'];
$poster=$row['poster'];
$views=$row['views'];
$wdate=sdatetime($row['wdate']);
echo "<tr bgcolor='#F0F0F0'>";
echo "<td>";
echo "<a href=/blog_article/$PHP_SELF/proc/view/amp;aid/$aid/amp;sid/$sid/amp;rid/$id/gt;.html";
echo " <font color=#836FFF>$banner</font>";
echo "</a>";
//echo "banner is $banner";
echo "</td>";
echo "<td>";
echo $poster;
echo "</td>";
echo "<td >";
echo " ";
echo "</td>";
echo "<td >";
echo $views;
echo "</td>";
echo "<td >";
echo $wdate;
echo "</td>";
echo "</tr>";
}
}
//========================================================================
function area() {
global $PHP_SELF;
global $aid,$sid,$pgno;
global $OPEN_LIST;
$showitems=20;
$DROOT=getenv('DOCUMENT_ROOT');
include("sql.php3");
$db=mysql_connect($sql['host'], $sql['user'] , $sql['passwd']);
//============================================================
if(!$aid) {
$qsql="SELECT id from bbs_area";
$rs=mysql_db_query($sql['db'],$qsql);
$row=mysql_fetch_array($rs);
$aid=$row['id'];
}
if(!$sid) {
$qsql="SELECT id from bbs_subj where aid=$aid order by wdate DESC";
$rs=mysql_db_query($sql['db'],$qsql);
$row=mysql_fetch_array($rs);
$sid=$row['id'];
}
if(!$pgno) {//礚﹚计
//$pgno=0;
$items=0;
$qsql="SELECT id from bbs_subj where aid=$aid order by wdate DESC";
$rs=mysql_db_query($sql['db'],$qsql);
while($row=mysql_fetch_array($rs)){
$id=$row['id'];
if($id==$sid) break;
$items++;
}
$pgno=(INT)($items/$showitems);
}
//============================================================
$qsql="SELECT * from bbs_area where id=$aid ";
$rs=mysql_db_query($sql['db'],$qsql);
$row=mysql_fetch_array($rs);
$banner=$row['banner'];
$body=$row['body'];
$master=$row['master'];
echo "<center><font color=GREEN size=5><b>$banner</b></font></center>";
echo "<FORM name=mtab ENCTYPE=multipart/form-data METHOD=POST ACTION=$PHP_SELF?proc=search>";
echo "<TABLE width=85% border=0 cellPadding=0 cellSpacing=1 align=center >";
echo "<tr><td>";
echo "<input type='hidden' name=aid value='$aid'>";
echo "穓碝ゅ彻:";
echo "<INPUT TYPE='TEXT' NAME='key' size=25 >";
echo "<INPUT TYPE='Submit'value='琩高' >";
echo "</td></tr>";
echo "</table>";
echo "</FORM>";
$qsql="SELECT * from bbs_subj where aid=$aid order by wdate DESC";
$rs=mysql_db_query($sql['db'],$qsql);
$all=mysql_num_rows($rs); //how rows
$pages=(INT)($all/$showitems); // how pages
$pgcount=$pgno*$showitems;
if($pgcount > $all) {
$pgno=$pages-1; // Page point over all pages
$pgcount=$pgno*$showitems;
}
mysql_data_seek($rs, $pgcount);
$cnt=0;
pagebar($pages);
echo "<TABLE width=85% border=0 cellPadding=0 cellSpacing=1 align=center bgcolor='#6CA6CD'>";
echo "<tr><td>";
echo "<TABLE width=100% cellPadding=1 cellSpacing=1 bgcolor=white >";
echo "<tr bgcolor=#F1E1FF>";
echo "<th >夹肈</th>";
echo "<th>祇癬</th>";
echo "<th width=30>莱</th>";
echo "<th width=30></th>";
echo "<th width=70>ら戳</th>";
echo "</tr>";
while($row=mysql_fetch_array($rs)) {
if(++$cnt > $showitems) break;
$id=$row['id'];
$banner=$row['banner'];
$poster=$row['poster'];
$views=$row['views'];
$wdate=sdatetime($row['wdate']);
$docs=reAnum($id);
echo "<tr bgcolor='#F0F8FF'>";
echo "<td>";
echo "<a href=/blog_article/$PHP_SELF/proc/view/amp;aid/$aid/amp;sid/$id/amp;rid/$id/gt;.html";
if($sid==$id) echo "<font color=red>〈$banner</font>";
else echo $banner;
echo "</a>";
echo "</td>";
echo "<td>";
echo $poster;
echo "</td>";
echo "<td >";
echo $docs;
echo "</td>";
echo "<td >";
echo $views;
echo "</td>";
echo "<td >";
echo $wdate;
echo "</td>";
echo "</tr>";
if($OPEN_LIST) openlist($id);
}
echo "</td></tr></table>";
echo"</td></tr></table>";
pagebar($pages);
}
待续........
最新技术文章: