$sql="SELECT * FROM tb"; //取得总信息数 $result=mysql_query($sql); $total=mysql_num_rows($result); //调用pageft(),每页显示10条信息(使用默认的20时,可以省略此参数),使用本页URL(默认,所以省略掉)。 pageft($total,10,"http://www.yemaosheng.com/index"); //现在产生的全局变量就派上用场了: $result=mysql_query($sql." limit $firstcount,$displaypg");
php
PHP数据库存储session
StandardFirst up, we need to create a table to handle the session data, and here's how it will look: CREATE TABLE sessions (ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, SessionID CHAR(26), Data TEXT DEFAULT '', DateTouched INT); Now, session operations script
PHP文件上传时关于open_basedir的报错解决
StandardPHP Upload files to the virtual host errors:
Warning: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect. File(/tmp/phpEIjcGh) is not within the allowed path(s): (/usr/local/apache/htdocs/) in /usr/local/apache/htdocs/xxxsite/upload.htm on line 21
Winxp上配Apache Mysql PHP及Linux上一些问题的备注
Standard1.如果PHP5按网上的教程还认不出Mysql Module的话就在Apache的httpd.conf头上加一句”loadfile c:/php/libmysql.dll”
公司考勤系统的数据结构及SQL
StandardCREATE TABLE IF NOT EXISTS tb_timecard (
timecard_id bigint(20) unsigned NOT NULL auto_increment,
timecard_user int(10) unsigned NOT NULL DEFAULT ” ,
timecard_ip varchar(16) NOT NULL DEFAULT ” ,
timecard_onduty datetime NOT NULL DEFAULT ” ,
timecard_offduty datetime NOT NULL DEFAULT ” ,
timecard_overtime datetime NOT NULL DEFAULT ” ,
timecard_memo tinytext ,
timecard_state tinyint(3) unsigned NOT NULL DEFAULT ‘0’ ,
PRIMARY KEY (timecard_id),
UNIQUE KEY timecard_id (timecard_id),
KEY timecard_id_2 (timecard_id),
KEY idx_datetime (timecard_offduty,timecard_onduty,timecard_overtime),
KEY idx_user (timecard_user)
);
<?php
$sql=”SELECT user_name,timecard_memo,timecard_ip,”;
$sql.=”CASE WHEN DATE_FORMAT(timecard_offduty,’%k:%i’)=’0:00′ “;
$sql.=”THEN “;
$sql.=”IF(DATE_FORMAT(timecard_overtime,’%k:%i’)<>’0:00′,TIME_FORMAT(TIMEDIFF(timecard_overtime,timecard_onduty),’%H:%i’),’00:00′) “;
$sql.=”ELSE TIME_FORMAT(TIMEDIFF(timecard_offduty,timecard_onduty),’%H:%i’) “;
$sql.=”END as t_worktime,”;
$sql.=”DATE_FORMAT(timecard_onduty,’%k:%i’) as t_onduty,”;
$sql.=”IF(DATE_FORMAT(timecard_offduty,’%k:%i’)<>’0:00′,DATE_FORMAT(timecard_offduty,’%k:%i’),”) as t_offduty,”;
$sql.=”IF(DATE_FORMAT(timecard_overtime,’%k:%i’)<>’0:00′,DATE_FORMAT(timecard_overtime,’%k:%i’),”) as t_overtime,”;
$sql.=”IF(DATE_FORMAT(timecard_overtime,’%k:%i’)<>’0:00′,TIME_FORMAT(TIMEDIFF(timecard_overtime,CONCAT(DATE_FORMAT(timecard_onduty,’%Y-%c-%d’),’ 18:00:00′)),’%H:%i’),”) as t_overtimeworktime,”;
$sql.=”DATE_FORMAT(timecard_onduty,’%Y-%m-%d %W’) as t_dateweek “;
$sql.=”FROM tb_timecard “;
$sql.=”INNER JOIN tb_user ON user_id=timecard_user “;
$sql.=”WHERE YEAR(NOW())=YEAR(timecard_onduty) and MONTH(timecard_onduty)=”.$_POST[‘select_month’].” and timecard_user=”.$_POST[‘select_user’].” “;
$sql.=”GROUP BY date_format(timecard_onduty,’%Y-%m-%d’) order by timecard_onduty”;
$result=mysql_query($sql);
while($row=mysql_fetch_array($result))
{
echo “总工作时间:”.$row[‘t_worktime’];
echo “上班考勤时间:”.$row[‘t_onduty’];
echo “下班考勤时间:”.$row[‘t_offduty’];
echo “加班时间:”.$row[‘t_overtimeworktime’];
}
?>