访问量一大功能就不能正确实现了,求高手帮忙优化两段PHP代码
第一段:
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
<?php
@session_start();
date_default_timezone_set('Asia/Shanghai');
$link_id =@ mysql_connect('localhost', 'root', 'password');
if ($link_id)
{
mysql_select_db('database');
mysql_query("set names 'utf8'"); //select 数据库之后加多这一句
}
else
{
echo "数据库连接错误!";
}
//var_dump($current);
$Datetime=date("Y-m-d G:i:s");//获取注册时间,也就是数据写入到用户表的时间
$bijiao="select max(current) from online";
$max=@mysql_query($bijiao,$link_id);
$most= intval( @mysql_result($max,0) );
$current= intval($_SESSION['current']);
$query="insert into online(current,mostcount,time) values('".$current."','".$most."','$Datetime')";
$result=mysql_query($query);
echo $most;
?>
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
<?php
@session_start();
date_default_timezone_set('Asia/Shanghai');
$link_id =@ mysql_connect('localhost', 'root', 'password');
if ($link_id)
{
mysql_select_db('database');
mysql_query("set names 'utf8'"); //select 数据库之后加多这一句
}
else
{
echo "数据库连接错误!";
}
$bijiao="select max(mostcount) from online";
$max=@mysql_query($bijiao,$link_id);
$most= intval( @mysql_result($max,0) );
$time="select time from online where mostcount='$most'";
$time=@mysql_query($time,$link_id);
$time=@mysql_result($time,0);
$already="select max(mostcount) from record";
$already=@mysql_query($already,$link_id);
$already= intval( @mysql_result($already,0) );
if($most>$already)
{
$query="insert into record(mostcount,time) values('".$most."','$time')";
$result=@mysql_query($query);
}
?>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号