当前位置: 编程技术>php
本页文章导读:
▪为查询结果建立向后/向前按钮
最近在Support Forums上有很多问题都是关于如何为一个搜索结果制作象"向后 1 2 3 4 5 向前"样子 的链接。我希望下面的脚本可以帮助你,在你的搜索结果页面中加入这种功能。这个例子是专为My.........
▪投票管理程序
投票管理程序 表结构 CREATE TABLE poll(Poll_Id INT (11) not null AUTO_INCREMENT,Poll_Name char(50) ,Poll_Del INT (10) DEFAULT '0' , PRIMARY KEY (Poll_Id)) CREATE TABLE pollsele(Pollsele_Id INT (11) not null AUTO_INCREMENT,Pollsele_Name .........
▪用PHP和ACCESS写聊天室(九)
enterrm.php3 代码如下: <?php $ConnID=@odbc_connect("jtfcht","admin",""); if ($ConnID){ $result=@odbc_exec($ConnID,"SELECT PassWord,LstTime,RoomID,RefRate FROM User WHERE UserID=".........
[1]为查询结果建立向后/向前按钮
来源: 互联网 发布时间: 2013-11-30
最近在Support Forums上有很多问题都是关于如何为一个搜索结果制作象"向后 1 2 3 4 5 向前"样子 的链接。我希望下面的脚本可以帮助你,在你的搜索结果页面中加入这种功能。这个例子是专为MySQL所写 的,但是对于其它的SQL引擎也可以很容易地适应。
因为每种应用都是不同的,这样我使用了一些通用的语句进行MySQL查询处理。TABLE名应该替换成你的 实际表名。YOUR CONDITIONAL HERE应该替换成你的where 条件,并且WHATEVER应该替换成你希望对结果进 行排序的字段(如果你的应用需要降序排列,不要忘记加上DESC)。
<?php
$limit=20; // 返回的行
$numresults=mysql_query("select * from TABLE where YOUR CONDITIONAL HERE order by WHATEVER");
$numrows=mysql_num_rows($numresults);
// 接着判断是否offset已经传给脚本了,如果没有设为0
if (empty($offset)) {
$offset=0;
}
// 取结果
$result=mysql_query("select id,name,phone ".
"from TABLE where YOUR CONDITIONAL HERE ".
"order by WHATEVER limit $offset,$limit");
// 现在可以显示返回结果了
while ($data=mysql_fetch_array($result)) {
// 在此处包含如你所愿的显示结果代码
}
// 接着我们需要生成其它结果的链接
if ($offset==1) { // 如果offset为0,则忽略PREV链接
$prevoffset=$offset-20;
print "<a href="/blog_article/$PHP_SELF/offset/$prevoffset.html">PREV</a> n";
}
// 计算需要链接的页面数
$pages=intval($numrows/$limit);
// 如果除后没有余数,$pages 现在包含需要页面的整数值
if ($numrows%$limit) {
// 如果有余数那么增加一页
$pages++;
}
for ($i=1;$i<=$pages;$i++) { // 循环
$newoffset=$limit*($i-1);
print "<a href="/blog_article/$PHP_SELF/offset/$newoffset.html">$i</a> n";
}
// 检查是否为最后一页
if (!(($offset/$limit)==$pages) && $pages!=1) {
// 如果不是下一页,则给出向后链接
$newoffset=$offset+$limit;
print "<a href="/blog_article/$PHP_SELF/offset/$newoffset.html">NEXT</a><p>n";
}
?>
这些对你来说可能有些用。当然,你可能想要使HTML的输出更干净一些...
而且,请注意在$PHP_SELF后的链接只包含了$offset。如果你需要为查询的where条件传递参数的话, 你也需也需要把这些补在上面。
因为每种应用都是不同的,这样我使用了一些通用的语句进行MySQL查询处理。TABLE名应该替换成你的 实际表名。YOUR CONDITIONAL HERE应该替换成你的where 条件,并且WHATEVER应该替换成你希望对结果进 行排序的字段(如果你的应用需要降序排列,不要忘记加上DESC)。
<?php
$limit=20; // 返回的行
$numresults=mysql_query("select * from TABLE where YOUR CONDITIONAL HERE order by WHATEVER");
$numrows=mysql_num_rows($numresults);
// 接着判断是否offset已经传给脚本了,如果没有设为0
if (empty($offset)) {
$offset=0;
}
// 取结果
$result=mysql_query("select id,name,phone ".
"from TABLE where YOUR CONDITIONAL HERE ".
"order by WHATEVER limit $offset,$limit");
// 现在可以显示返回结果了
while ($data=mysql_fetch_array($result)) {
// 在此处包含如你所愿的显示结果代码
}
// 接着我们需要生成其它结果的链接
if ($offset==1) { // 如果offset为0,则忽略PREV链接
$prevoffset=$offset-20;
print "<a href="/blog_article/$PHP_SELF/offset/$prevoffset.html">PREV</a> n";
}
// 计算需要链接的页面数
$pages=intval($numrows/$limit);
// 如果除后没有余数,$pages 现在包含需要页面的整数值
if ($numrows%$limit) {
// 如果有余数那么增加一页
$pages++;
}
for ($i=1;$i<=$pages;$i++) { // 循环
$newoffset=$limit*($i-1);
print "<a href="/blog_article/$PHP_SELF/offset/$newoffset.html">$i</a> n";
}
// 检查是否为最后一页
if (!(($offset/$limit)==$pages) && $pages!=1) {
// 如果不是下一页,则给出向后链接
$newoffset=$offset+$limit;
print "<a href="/blog_article/$PHP_SELF/offset/$newoffset.html">NEXT</a><p>n";
}
?>
这些对你来说可能有些用。当然,你可能想要使HTML的输出更干净一些...
而且,请注意在$PHP_SELF后的链接只包含了$offset。如果你需要为查询的where条件传递参数的话, 你也需也需要把这些补在上面。
[2]投票管理程序
来源: 互联网 发布时间: 2013-11-30
投票管理程序
表结构
CREATE TABLE poll(Poll_Id INT (11) not null AUTO_INCREMENT,Poll_Name char(50) ,Poll_Del INT (10) DEFAULT '0' , PRIMARY KEY (Poll_Id))
CREATE TABLE pollsele(Pollsele_Id INT (11) not null AUTO_INCREMENT,Pollsele_Name char(50) ,Poll_Del INT (10) DEFAULT '0' , Pollsele_poll_Id INT (10) ,pollsele_num int (10), PRIMARY KEY (Pollsele_Id))
-------------------------------------------------------------------------------------------------
poll.php //主程序
<? $db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="select poll_id,Poll_Name from poll where poll_del='1'";
@$result = mysql_query($sql);
$myrow=mysql_fetch_row($result);
echo "<table align=center bgcolor=aabbcc width=250 hight=450 border=0 >";
echo "<td align=center bgcolor=99aabb >";
echo "$myrow[1]";
$sql="select Pollsele_Name,pollsele_poll_id from pollsele where pollsele_del='0' and pollsele_poll_id='$myrow[0]'";
@$result = mysql_query($sql);
echo "<FORM ACTION='/blog_article/pollsee/poll_id/$myrow[0].html' METHOD='post' target=_blank>";
echo "<p align=center>";
while($myrow=mysql_fetch_row($result))
{
echo "<input type='radio' name=toupiao value='$myrow[0]'>$myrow[0]";
echo " "; }
echo "<br>"; echo "<br>";
echo "<input type=submit name=submit value='投票' >";
echo "</p>";
echo "</form>"; echo "</td>";
echo "</table>";
mysql_close();
echo "<br>";
echo "<p align=right>";
echo "<a href=/blog_article/poll_input>管理</a>/index.html"; echo "</p>"; ?>
-----------------------------------------------------------------------
poll_input.php //添加主题
<? $db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="select poll_id,poll_name,poll_del from poll";
echo "<table width=300 hight=560 bgcolor=aabbcc align=center >";
$result=mysql_query($sql);
while($my=mysql_fetch_row($result))
{
echo "<tr>";echo "<td align=center width=50 bgcolor=99aabb >";echo $my[0];echo "</td>";
echo "<td align=center width=200 bgcolor=99aabb ><a href=/blog_article/pollsele/id/$my[0]/gt;$my[1]/lt;/a/gt;/lt;/td/gt;.html";
echo "<td align=center width=50 bgcolor=99aabb >";echo $my[2];echo "</td>";
echo "</tr>";
} echo "</table>";
?>
<html>
<head>
<?
if($submit2!="添加")
{ echo "<p align=center>";
echo "<FORM ACTION='/blog_article/poll_input.html' METHOD='post'>";
echo "<font color=004080>主题:</font>";
echo "<input type=text name=title size=30 value=''>";
echo "<input type=submit name=submit2 value='添加'>";
echo "</p>";
echo"</form>"; }
else
{$db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="select poll_name from poll where poll_name='$title'";
mysql_query($sql);
$sql="insert into poll values('','$title','')";
mysql_query($sql);
mysql_close();
echo "<META HTTP-EQUIV=REFRESH CONTENT='1; URL=poll_input.php'>"; }
if($submit1!="有效"&&$submit3!="删除")
{ echo "<p align=center>";
echo "<FORM ACTION='/blog_article/poll_input.html' METHOD='post'>";
echo "<font color=004080>设置主题:</font>";
echo "<select name='sele' size=1>";
$db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="select Poll_Id from poll";
$result = mysql_query($sql);
mysql_close();
while($myrow=mysql_fetch_row($result))
{ echo "<option value='$myrow[0]'>$myrow[0]";}
echo "</select>";
echo "<input type=submit name=submit1 value='有效'>";
echo "<input type=submit name=submit3 value='删除'>";
echo "</p>";
echo "</FORM>";
}
else
{
if($submit1=="有效")
{
$db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="update poll set Poll_Del='0'";
$result = mysql_query($sql);
$sql="update poll set Poll_Del='1' where poll_id='$sele'";
$result = mysql_query($sql);
mysql_close();
echo "<META HTTP-EQUIV=REFRESH CONTENT='1; URL=poll_input.php'>"; }
else
{ $db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="delete from poll where poll_id='$sele'";
$result = mysql_query($sql);
$sql="delete from pollsele where pollsele_poll_id='$sele'";
mysql_query($sql);
mysql_close();
echo "<META HTTP-EQUIV=REFRESH CONTENT='1; URL=poll_input.php'>"; }
}
?>
--------------------------------------------------------------------
pollsele.php //添加选项
<? $db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="select pollsele_id,pollsele_name,pollsele_del,pollsele_num from pollsele where pollsele_poll_id='$id'";
echo "<table width=300 hight=560 align=center bgcolor=aabbcc >";
@$result=mysql_query($sql);
while($my=mysql_fetch_row($result))
{
echo "<tr>";echo "<td align=center width=50 bgcolor=99aabb >";echo $my[0];echo "</td>";
echo "<td align=center width=200 bgcolor=99aabb >$my[1]</td>";
echo "<td align=center width=50 bgcolor=99aabb >";echo $my[2];echo "</td>";
echo "<td align=center width=50 bgcolor=99aabb >";echo $my[3];echo "</td>";
echo "</tr>";
} echo "</table>";
?>
<html>
<head>
<?
if($submit2!="添加")
{ echo "<p align=center>";
echo "<FORM ACTION='/blog_article/pollsele/id/$id.html' METHOD='post'>";
echo "<font color=004080>选项:</font></td>";
echo "<input type=text name=title size=30 value=''>";
echo "<input type=submit name=submit2 value='添加'>";
echo "</p>";
echo"</form>"; }
else
{$db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="insert into pollsele values('','$title','','$id','')";
mysql_query($sql);
mysql_close();
echo "<META HTTP-EQUIV=REFRESH CONTENT='1; URL=pollsele.php?id=$id'>"; }
if($submit1!="有效"&&$submit3!="无效")
{ echo "<p align=center>";
echo "<FORM ACTION='/blog_article/pollsele/id/$id.html' METHOD='post'>";
echo "<font color=004080>设置选项:</font>";
echo "<select name='sele' size=1>";
$db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="select Pollsele_Id from pollsele where pollsele_poll_id='$id'";
$result = mysql_query($sql);
mysql_close();
while($myrow=mysql_fetch_row($result))
{ echo "<option value='$myrow[0]'>$myrow[0]";}
echo "</select>";
echo "<input type=submit name=submit1 value='有效'>";
echo "<input type=submit name=submit3 value='无效'>";
echo "</p>";
echo "</FORM>";
}
else
{ $db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
if ($submit1=="有效")
{
$sql="update pollsele set Pollsele_Del='0' where pollsele_id='$sele'";
$result = mysql_query($sql);}
else
{
$sql="update pollsele set Pollsele_Del='1' where pollsele_id='$sele'";
$result = mysql_query($sql); }
mysql_close();
echo "<META HTTP-EQUIV=REFRESH CONTENT='1; URL=pollsele.php?id=$id'>"; }
?>
----------------------------------------------------------------------
pollsee.php //投票结果
<? if ($toupiao!=""){
$db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="select Pollsele_Name,pollsele_num from pollsele where pollsele_name='$toupiao'";
@$result = mysql_query($sql);
$myrow=mysql_fetch_row($result);
$poll_num=$myrow[1];
$poll_num=$poll_num+1;
$sql="update pollsele set Pollsele_num='$poll_num' where pollsele_name='$toupiao'";
mysql_query($sql);
$sql="select Poll_Name from poll where poll_id='$poll_id'";
@$result = mysql_query($sql);
$title=mysql_fetch_row($result);
echo "<p align=center>";
echo $title[0]; echo "</p>";
echo "<br>";
$sql="select Pollsele_Name,pollsele_num from pollsele where pollsele_del='0' and pollsele_poll_id='$poll_id'";
@$result = mysql_query($sql);
echo "<table align=center bgcolor=aabbcc >";
while($myrow=mysql_fetch_row($result))
{ echo "<tr>"; echo "<td width=150 bgcolor=99aabb >";
echo $myrow[0];echo "</td><td width=50 bgcolor=99aabb >";echo $myrow[1]; echo "</td></tr>";} echo "</table>"; }
else
{echo "<font color=red>你不能投空票!!!</font>";}
?>
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】
表结构
CREATE TABLE poll(Poll_Id INT (11) not null AUTO_INCREMENT,Poll_Name char(50) ,Poll_Del INT (10) DEFAULT '0' , PRIMARY KEY (Poll_Id))
CREATE TABLE pollsele(Pollsele_Id INT (11) not null AUTO_INCREMENT,Pollsele_Name char(50) ,Poll_Del INT (10) DEFAULT '0' , Pollsele_poll_Id INT (10) ,pollsele_num int (10), PRIMARY KEY (Pollsele_Id))
-------------------------------------------------------------------------------------------------
poll.php //主程序
<? $db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="select poll_id,Poll_Name from poll where poll_del='1'";
@$result = mysql_query($sql);
$myrow=mysql_fetch_row($result);
echo "<table align=center bgcolor=aabbcc width=250 hight=450 border=0 >";
echo "<td align=center bgcolor=99aabb >";
echo "$myrow[1]";
$sql="select Pollsele_Name,pollsele_poll_id from pollsele where pollsele_del='0' and pollsele_poll_id='$myrow[0]'";
@$result = mysql_query($sql);
echo "<FORM ACTION='/blog_article/pollsee/poll_id/$myrow[0].html' METHOD='post' target=_blank>";
echo "<p align=center>";
while($myrow=mysql_fetch_row($result))
{
echo "<input type='radio' name=toupiao value='$myrow[0]'>$myrow[0]";
echo " "; }
echo "<br>"; echo "<br>";
echo "<input type=submit name=submit value='投票' >";
echo "</p>";
echo "</form>"; echo "</td>";
echo "</table>";
mysql_close();
echo "<br>";
echo "<p align=right>";
echo "<a href=/blog_article/poll_input>管理</a>/index.html"; echo "</p>"; ?>
-----------------------------------------------------------------------
poll_input.php //添加主题
<? $db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="select poll_id,poll_name,poll_del from poll";
echo "<table width=300 hight=560 bgcolor=aabbcc align=center >";
$result=mysql_query($sql);
while($my=mysql_fetch_row($result))
{
echo "<tr>";echo "<td align=center width=50 bgcolor=99aabb >";echo $my[0];echo "</td>";
echo "<td align=center width=200 bgcolor=99aabb ><a href=/blog_article/pollsele/id/$my[0]/gt;$my[1]/lt;/a/gt;/lt;/td/gt;.html";
echo "<td align=center width=50 bgcolor=99aabb >";echo $my[2];echo "</td>";
echo "</tr>";
} echo "</table>";
?>
<html>
<head>
<?
if($submit2!="添加")
{ echo "<p align=center>";
echo "<FORM ACTION='/blog_article/poll_input.html' METHOD='post'>";
echo "<font color=004080>主题:</font>";
echo "<input type=text name=title size=30 value=''>";
echo "<input type=submit name=submit2 value='添加'>";
echo "</p>";
echo"</form>"; }
else
{$db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="select poll_name from poll where poll_name='$title'";
mysql_query($sql);
$sql="insert into poll values('','$title','')";
mysql_query($sql);
mysql_close();
echo "<META HTTP-EQUIV=REFRESH CONTENT='1; URL=poll_input.php'>"; }
if($submit1!="有效"&&$submit3!="删除")
{ echo "<p align=center>";
echo "<FORM ACTION='/blog_article/poll_input.html' METHOD='post'>";
echo "<font color=004080>设置主题:</font>";
echo "<select name='sele' size=1>";
$db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="select Poll_Id from poll";
$result = mysql_query($sql);
mysql_close();
while($myrow=mysql_fetch_row($result))
{ echo "<option value='$myrow[0]'>$myrow[0]";}
echo "</select>";
echo "<input type=submit name=submit1 value='有效'>";
echo "<input type=submit name=submit3 value='删除'>";
echo "</p>";
echo "</FORM>";
}
else
{
if($submit1=="有效")
{
$db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="update poll set Poll_Del='0'";
$result = mysql_query($sql);
$sql="update poll set Poll_Del='1' where poll_id='$sele'";
$result = mysql_query($sql);
mysql_close();
echo "<META HTTP-EQUIV=REFRESH CONTENT='1; URL=poll_input.php'>"; }
else
{ $db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="delete from poll where poll_id='$sele'";
$result = mysql_query($sql);
$sql="delete from pollsele where pollsele_poll_id='$sele'";
mysql_query($sql);
mysql_close();
echo "<META HTTP-EQUIV=REFRESH CONTENT='1; URL=poll_input.php'>"; }
}
?>
--------------------------------------------------------------------
pollsele.php //添加选项
<? $db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="select pollsele_id,pollsele_name,pollsele_del,pollsele_num from pollsele where pollsele_poll_id='$id'";
echo "<table width=300 hight=560 align=center bgcolor=aabbcc >";
@$result=mysql_query($sql);
while($my=mysql_fetch_row($result))
{
echo "<tr>";echo "<td align=center width=50 bgcolor=99aabb >";echo $my[0];echo "</td>";
echo "<td align=center width=200 bgcolor=99aabb >$my[1]</td>";
echo "<td align=center width=50 bgcolor=99aabb >";echo $my[2];echo "</td>";
echo "<td align=center width=50 bgcolor=99aabb >";echo $my[3];echo "</td>";
echo "</tr>";
} echo "</table>";
?>
<html>
<head>
<?
if($submit2!="添加")
{ echo "<p align=center>";
echo "<FORM ACTION='/blog_article/pollsele/id/$id.html' METHOD='post'>";
echo "<font color=004080>选项:</font></td>";
echo "<input type=text name=title size=30 value=''>";
echo "<input type=submit name=submit2 value='添加'>";
echo "</p>";
echo"</form>"; }
else
{$db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="insert into pollsele values('','$title','','$id','')";
mysql_query($sql);
mysql_close();
echo "<META HTTP-EQUIV=REFRESH CONTENT='1; URL=pollsele.php?id=$id'>"; }
if($submit1!="有效"&&$submit3!="无效")
{ echo "<p align=center>";
echo "<FORM ACTION='/blog_article/pollsele/id/$id.html' METHOD='post'>";
echo "<font color=004080>设置选项:</font>";
echo "<select name='sele' size=1>";
$db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="select Pollsele_Id from pollsele where pollsele_poll_id='$id'";
$result = mysql_query($sql);
mysql_close();
while($myrow=mysql_fetch_row($result))
{ echo "<option value='$myrow[0]'>$myrow[0]";}
echo "</select>";
echo "<input type=submit name=submit1 value='有效'>";
echo "<input type=submit name=submit3 value='无效'>";
echo "</p>";
echo "</FORM>";
}
else
{ $db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
if ($submit1=="有效")
{
$sql="update pollsele set Pollsele_Del='0' where pollsele_id='$sele'";
$result = mysql_query($sql);}
else
{
$sql="update pollsele set Pollsele_Del='1' where pollsele_id='$sele'";
$result = mysql_query($sql); }
mysql_close();
echo "<META HTTP-EQUIV=REFRESH CONTENT='1; URL=pollsele.php?id=$id'>"; }
?>
----------------------------------------------------------------------
pollsee.php //投票结果
<? if ($toupiao!=""){
$db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="select Pollsele_Name,pollsele_num from pollsele where pollsele_name='$toupiao'";
@$result = mysql_query($sql);
$myrow=mysql_fetch_row($result);
$poll_num=$myrow[1];
$poll_num=$poll_num+1;
$sql="update pollsele set Pollsele_num='$poll_num' where pollsele_name='$toupiao'";
mysql_query($sql);
$sql="select Poll_Name from poll where poll_id='$poll_id'";
@$result = mysql_query($sql);
$title=mysql_fetch_row($result);
echo "<p align=center>";
echo $title[0]; echo "</p>";
echo "<br>";
$sql="select Pollsele_Name,pollsele_num from pollsele where pollsele_del='0' and pollsele_poll_id='$poll_id'";
@$result = mysql_query($sql);
echo "<table align=center bgcolor=aabbcc >";
while($myrow=mysql_fetch_row($result))
{ echo "<tr>"; echo "<td width=150 bgcolor=99aabb >";
echo $myrow[0];echo "</td><td width=50 bgcolor=99aabb >";echo $myrow[1]; echo "</td></tr>";} echo "</table>"; }
else
{echo "<font color=red>你不能投空票!!!</font>";}
?>
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】
[3]用PHP和ACCESS写聊天室(九)
来源: 互联网 发布时间: 2013-11-30
enterrm.php3
代码如下:
<?php
$ConnID=@odbc_connect("jtfcht","admin","");
if ($ConnID){
$result=@odbc_exec($ConnID,"SELECT PassWord,LstTime,RoomID,RefRate FROM User WHERE UserID=".$id);
if (@odbc_fetch_into($result,0,&$rArr)){
$sRoomID=$rArr[2];
$sRefRate=(int)$rArr[3];
if ($sRefRate<2) $sRefRate=2;
if (($rArr[0]==$ps) && ($rArr[1]>=(time()-1800))){
$sNewRoomID=substr($selRoom,2);
if ($sNewRoomID!=$sRoomID){
$result=@odbc_exec($ConnID,"SELECT Password FROM Room WHERE RoomID=".$sNewRoomID);
if (@odbc_fetch_into($result,0,&$rArr)){
if ((strlen(trim($rArr[0]))==0) || ($rArr[0]==$sPass)){
@odbc_exec($ConnID,"UPDATE User SET RoomID=".$sNewRoomID.",ToID=0,ToName='大家' WHERE UserID=".$id);
if ((int)$sRoomID!=1){
$result=@odbc_exec($ConnID,"SELECT COUNT(UserID) FROM User WHERE RoomID=".$sRoomID);
@odbc_fetch_into($result,0,&$rArr);
if ($rArr[0]==0) @odbc_exec($ConnID,"DELETE * FROM Room Where RoomID=".$sRoomID);
}
}
else{
?>
<html>
<head>
<title>输入房间口令</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="/blog_article/main.css" type="text/css">
<script language="JavaScript">
<!--
function PassSetFocus( ) {
document.frmEnterSm.sPass.focus();
}
//-->
</script>
<link rel="stylesheet" href="/blog_article/main.css" type="text/css">
</head>
<body onload="PassSetFocus();">
<p> </p>
<p align="center"><font color="#996666">输入房间口令</font></p>
<form name="frmEnterSm" action="/blog_article/enterrm.html" method="post">
<table width="100%" border="0" align="center">
<tr>
<td colspan="2"><input type="hidden" name="selRoom" value="<?php echo $selRoom; ?>"><input type="hidden" name="id" value="<?php echo $id; ?>"><input type="hidden" name="ps" value="<?php echo $ps; ?>"></td>
</tr>
<tr>
<td width="40%" align="right">口令:</td>
<td width="60%"><input type="password" name="sPass" maxlength="10" size="8"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="cmdYes" value="进入"></td>
</tr>
</table>
</form>
<p align="center">按<a href="/blog_article/room/id/lt;php echo $id; /gt;/amp;ps/lt;php echo $ps; /gt;/amp;at/lt;php echo time(); /gt;.html">这里</a>放弃</p>
</body>
</html>
<?php
exit();
}
}
else{
?>
<html>
<head>
<title>加入房间出错</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="/blog_article/main.css" type="text/css">
</head>
<body>
<p> </p>
<p align="center">这个房间已经被拆了!</p>
<p align="center">按<a href="/blog_article/room/id/lt;php echo $id; /gt;/amp;ps/lt;php echo $ps; /gt;/amp;at/lt;php echo time(); /gt;.html">这里</a>返回</p>
</body>
</html>
<?php
exit();
}
}
}
else echo "<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'><title>房间</title><link rel='stylesheet' href='main.css' type='text/css'></head><body></body></html>";
}
else echo "<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'><title>房间</title><link rel='stylesheet' href='main.css' type='text/css'></head><body></body></html>";
@odbc_close($ConnID);
}
else echo "<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'><title>房间</title><link rel='stylesheet' href='main.css' type='text/css'></head><body></body></html>";
include("room.php3");
?>
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】
代码如下:
<?php
$ConnID=@odbc_connect("jtfcht","admin","");
if ($ConnID){
$result=@odbc_exec($ConnID,"SELECT PassWord,LstTime,RoomID,RefRate FROM User WHERE UserID=".$id);
if (@odbc_fetch_into($result,0,&$rArr)){
$sRoomID=$rArr[2];
$sRefRate=(int)$rArr[3];
if ($sRefRate<2) $sRefRate=2;
if (($rArr[0]==$ps) && ($rArr[1]>=(time()-1800))){
$sNewRoomID=substr($selRoom,2);
if ($sNewRoomID!=$sRoomID){
$result=@odbc_exec($ConnID,"SELECT Password FROM Room WHERE RoomID=".$sNewRoomID);
if (@odbc_fetch_into($result,0,&$rArr)){
if ((strlen(trim($rArr[0]))==0) || ($rArr[0]==$sPass)){
@odbc_exec($ConnID,"UPDATE User SET RoomID=".$sNewRoomID.",ToID=0,ToName='大家' WHERE UserID=".$id);
if ((int)$sRoomID!=1){
$result=@odbc_exec($ConnID,"SELECT COUNT(UserID) FROM User WHERE RoomID=".$sRoomID);
@odbc_fetch_into($result,0,&$rArr);
if ($rArr[0]==0) @odbc_exec($ConnID,"DELETE * FROM Room Where RoomID=".$sRoomID);
}
}
else{
?>
<html>
<head>
<title>输入房间口令</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="/blog_article/main.css" type="text/css">
<script language="JavaScript">
<!--
function PassSetFocus( ) {
document.frmEnterSm.sPass.focus();
}
//-->
</script>
<link rel="stylesheet" href="/blog_article/main.css" type="text/css">
</head>
<body onload="PassSetFocus();">
<p> </p>
<p align="center"><font color="#996666">输入房间口令</font></p>
<form name="frmEnterSm" action="/blog_article/enterrm.html" method="post">
<table width="100%" border="0" align="center">
<tr>
<td colspan="2"><input type="hidden" name="selRoom" value="<?php echo $selRoom; ?>"><input type="hidden" name="id" value="<?php echo $id; ?>"><input type="hidden" name="ps" value="<?php echo $ps; ?>"></td>
</tr>
<tr>
<td width="40%" align="right">口令:</td>
<td width="60%"><input type="password" name="sPass" maxlength="10" size="8"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="cmdYes" value="进入"></td>
</tr>
</table>
</form>
<p align="center">按<a href="/blog_article/room/id/lt;php echo $id; /gt;/amp;ps/lt;php echo $ps; /gt;/amp;at/lt;php echo time(); /gt;.html">这里</a>放弃</p>
</body>
</html>
<?php
exit();
}
}
else{
?>
<html>
<head>
<title>加入房间出错</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="/blog_article/main.css" type="text/css">
</head>
<body>
<p> </p>
<p align="center">这个房间已经被拆了!</p>
<p align="center">按<a href="/blog_article/room/id/lt;php echo $id; /gt;/amp;ps/lt;php echo $ps; /gt;/amp;at/lt;php echo time(); /gt;.html">这里</a>返回</p>
</body>
</html>
<?php
exit();
}
}
}
else echo "<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'><title>房间</title><link rel='stylesheet' href='main.css' type='text/css'></head><body></body></html>";
}
else echo "<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'><title>房间</title><link rel='stylesheet' href='main.css' type='text/css'></head><body></body></html>";
@odbc_close($ConnID);
}
else echo "<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'><title>房间</title><link rel='stylesheet' href='main.css' type='text/css'></head><body></body></html>";
include("room.php3");
?>
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】
最新技术文章: