数据库资料显示/修改的基本操作
SQL:
[coolcode]
# 表的结构 `staff_level`
#
CREATE TABLE `staff_level` (
`id` tinyint(2) unsigned NOT NULL auto_increment,
`code` char(4) NOT NULL,
`name` varchar(20) NOT NULL,
`time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;
#
# 导出表中的数据 `staff_level`
#
INSERT INTO `staff_level` VALUES (1, ‘G1’, ‘公司总经理’, ‘2006-11-22 22:30:19’);
INSERT INTO `staff_level` VALUES (2, ‘G2’, ‘分公司经理’, ‘2006-11-23 09:15:33’);
INSERT INTO `staff_level` VALUES (3, ‘G3’, ‘部门总经理’, ‘2006-11-23 09:15:39’);
INSERT INTO `staff_level` VALUES (4, ‘G4’, ‘部门经理’, ‘2006-11-23 08:49:52’);
INSERT INTO `staff_level` VALUES (5, ‘A1’, ‘系统管理员’, ‘2006-11-23 09:16:44’);
INSERT INTO `staff_level` VALUES (6, ‘T1’, ‘讲师’, ‘2006-11-23 09:11:03’);
INSERT INTO `staff_level` VALUES (7, ‘S1’, ‘学员’, ‘2006-11-23 09:11:11’);
INSERT INTO `staff_level` VALUES (8, ‘G5’, ‘员工’, ‘2006-11-23 11:13:50’);
[/coolcode]
列表:
[coolcode]
/*
* 2006年9月15日
* 添加 function get_substr($string,$start,$length)
* 主要实现字符的截取
*/
function get_substr($string,$start,$length)
{
$i = 0;
while($i<$start)
{
if(ord($string[$i])>127)
{
$i = $i+2;
}
else
{
$i++;
}
}
$start = $i;
$end = $start+$length;
while($i<$end)
{
if(ord($string[$i])>127)
{
$i = $i+2;
}
else
{
$i++;
}
}
if($end != $i-1)
{
$end = $i;
}
else
{
$end–;
}
$length = $end-$start;
return substr($string,$start,$length);
}
if(!empty($_POST[‘title’])){
$plan[‘title’] = $_POST[‘title’];
$plan[‘kind’] = $_POST[‘kind’];
$plan[‘classname’] = $_POST[‘classname’];
$plan[‘department’] = $_POST[‘department’];
$plan[‘personaccount’] = $_POST[‘personaccount’];
$plan[‘time’] = $_POST[‘time’];
$plan[‘content’] = $_POST[‘content’];
$plan[‘teacher’] = $_POST[‘teacher’];
$plan[‘schoolbook’] = $_POST[‘schoolbook’];
$plan[‘place’] = $_POST[‘place’];
$plan[‘note’] = $_POST[‘note’];
$n=1;
$field = ”;
$values = ”;
foreach($plan as $key=>$value){
if(!empty($value)){
$field .= (‘`’.$key.’`,’);
$values .= (‘”‘.$value.'”,’);
}
}
//$field = preg_replace(‘/,$/i’,”,$field);
//$values = preg_replace(‘/,$/i’,”,$values);
$sql =”INSERT INTO training_plan ($field `update_time`) VALUES ($values NOW())”;
$result=api_sql_query($sql,__FILE__,__LINE__);
if($result){
echo ““;
}
}
$currentpage = isset($_GET[‘page’]) ? $_GET[‘page’] : ‘1’;
?>
您的位置:年度培训计划
,
当前 “.get_lang(‘UsersOnline’).”: “.$number.”人“;
}?>
年度培训计划
编号 | 计划名称 | 更新时间 | 管理功能 | 目前没有信息! |
---|---|---|---|
“.$row[0].” | “.get_substr($row[1],0,20).” | “.substr($row[2],0,10).” | 查看 修改 删除 |
2025 | “.get_substr(‘管理型态的变革对主管产生的影响管理型态的变革对主管产生的影响’,0,40).” | “.substr($row[2],0,10).” | 查看 修改 删除 |
目前没有信息! |
“;
?>
//分页 if(!empty($total)){ $totalpage = ceil($total/10); $foot = "
“;if($currentpage==1 && $currentpage<$totalpage){ $foot .= '
‘;
}
elseif($currentpage>1 && $currentpage<$totalpage){
$foot .= '
}
elseif($currentpage>1 && $currentpage==$totalpage){
$foot .= ‘
‘;
}
$foot .=”
echo $foot;
}
?>
添加新计划
[/coolcode]
显示:
[coolcode]
if(!empty($_GET['id'])){
$id = $_GET['id'];
$sql ="SELECT * FROM training_plan WHERE `id`= $id";
$result=api_sql_query($sql,__FILE__,__LINE__);
if($result){
$data = mysql_fetch_assoc($result);
}
}
else{
echo "“;
exit;
}
?>
您的位置:年度培训计划
,
当前 “.get_lang(‘UsersOnline’).”: “.$number.”人“;
}?>
年度培训计划
//print_r($data); ?>
[/coolcode]
修改:
[coolcode]
require('./claroline/inc/claro_init_global.inc.php');
api_block_anonymous_users();
include (api_get_library_path().'/resourcemanagements.lib.php');
if(!empty($_GET['id'])){
$id = $_GET['id'];
$sql ="SELECT * FROM training_plan WHERE `id`= $id";
$result=api_sql_query($sql,__FILE__,__LINE__);
if($result){
$data = mysql_fetch_assoc($result);
}
}
else{
echo "“;
exit;
}
?>
您的位置:年度培训计划
,
当前 “.get_lang(‘UsersOnline’).”: “.$number.”人“;
}?>
年度培训计划
//print_r($data); ?>
[/coolcode]