Mysql,Bootstrap,工具提示,我正在努力提高自己的能力,所以我想到了更好的学习方法,而不是跳入仪式。
我在这个网站和其他网站上找到了许多问题的答案,但随着我的项目变得越来越复杂,找到答案变得越来越困难。
我编写了这个脚本,它似乎在Firefox和IE中完美运行(我想要它的确切),但出于某些原因,在Dreamweaver的实时功能中,它显示了一些它不应该出现的Php。就好像有错误一样。但是Firefox和IE再次没有显示错误,事实上一切都在浏览器中完美运行。 这是我正在使用的代码。
也许我的代码只是草率,因为你可以看到我进出PHP太多了。 所以在Dreamweaver中有两个子弹点和代码片段: 会员登录并激活。 当我选择直播时,这就是我的Dreamweaver中显示的内容。
: =“2”){echo $ hours; ?>小时,分钟分钟
我不确定为什么代码显示它不应该在实时版本中。
我可以从愿意帮助的人那里学到很多东西。谢谢。
<?php
include("db.php");
$con=mysql_connect($server, $db_user, $db_pwd) //connect to the database server
or die ("Could not connect to mysql because ".mysql_error());
mysql_select_db($db_name) //select the database
or die ("Could not select to mysql because ".mysql_error());
#//////////////////////////////////////////////////////////////////////////
$time = time(); #Current time
$previous = "86400"; #Time to check in seconds (24 hours)
$logout = $time-$previous; #Timeout=time - 24hours
# /////////////////////////////////////////////////////////////////////////////
$time1 = time(); #Current time
$previous1 = "600"; #Time to check in seconds
$lagout1 = $time1-$previous1; #Timeout=time - 10 minutes
#/////////////////////////loggedin AND lagged in //////////////////////////////
//prevent sql injection
//$username=mysql_real_escape_string($_POST["username"]);
//$password=mysql_real_escape_string($_POST["password"]);
$query = "SELECT * FROM ".$table_name." WHERE logout > \"$logout\" AND lagout >
\"$lagout1\" ORDER BY username ASC";
$online = mysql_query($query); #Execute query
$row_online = mysql_fetch_assoc($online); #Grab the users
if (isset($row_online['username'])) { #If there is atleast one user online
do { #Do this
?>
<div id="effect2" >
<li><a href="#"><?php echo $row_online['username']; ?></a><span><?php echo $row_online['username']; ?>:<br /><font color='yellow'>Member logged in and active. </font></span></li>
</div>
<?
} while($row_online = mysql_fetch_assoc($online)); #Until all records are displayed
}
?>
<?
#//////////////////Logged in BUT lagged out////////////////////////////////
$query = "SELECT * FROM ".$table_name." WHERE logout > \"$logout\" AND lagout < \"$lagout1\" ORDER BY username ASC "; #Check and see who is online in the last 2 minutes
$online = mysql_query($query); #Execute query
$row_online = mysql_fetch_assoc($online); #Grab the users
if (isset($row_online['username'])) { #If there is atleast one user online
do { #Do this
?>
<?
$T = time();
$lagT = $row_online['logout'];
$S = $T - $lagT;
$init = $S;
$hours = floor($init / 3600);
$minutes = floor(($init / 60) % 60);
$seconds = $init % 60;
?>
<div id="effect2" >
<li><a href="#"><font color='#333333'><?php echo $row_online['username']; ?></font> </a><span><?php echo $row_online['username']; ?>:<br />
Idle for: <font color='red'>
<? if ($hours == "1") {
echo $hours; ?> Hour, <? echo $minutes; ?> Minutes
</font></span></li>
<? }elseif ($hours >= "2") {
echo $hours; ?> Hours, <? echo $minutes; ?> Minutes
</font></span></li>
<? } elseif ($hours <= "1") {
echo $minutes; ?> Minutes
</font></span></li>
<? } ?>
</div>
<?
} while($row_online = mysql_fetch_assoc($online)); #Until all records are displayed
}
?>
<div style="position: absolute; 10px; center: 14px; top: 286px; 90px; top: 294px; left: 10px;">
<?
#//////////////////////////////////// there are no more members online ///////////////
echo "_________________________<br /><center>Members who have logged <br />off do not show on this list.</center>"; #Inform user that no one is online
?>
</div>
</div>