我就是呀~~要是不用oop~~那可真的落伍了~~~ :)
不过用过之后~~你就会发现它的好了
不过用过之后~~你就会发现它的好了
解决方案 »
- Zend Studio 7.2模板中文乱码(New PHP file - HTML frameset)
- asp 或者php获取远程页面html 生成dom树
- 急求:iis+php+mysql的问题(Apache+hph+Mysql正常)(同一站点目录)
- php交流群,新建200人高级群:66589844
- 新手上路
- 在线播放器连接速度奇慢,救解决办法
- 关于批量生成!
- 在线等:fseek($fp, $sub, SEEK_SET);部分把$fp换成字符串的话如何修改?
- 小弟搞了这个论坛,大家去看看,里有免费代理服务器和免费做QQ会员的方法.
- 关于ueditor编辑器多张图片上传
- 怎样用php统计网页日访量和周访量?
- 应该怎么配置呢?
的session部分,有问题的 :-)
特别是数据库处理部分另外,自己在平常的积累中,积累了一些好的Class和function
phplib的资料,加入自己的方法和思想,以及收集到得好的class和func
如何?各位。
<?php
//*********************************************
// 名称: 数据操作程序 v 1.0
// 脚本: php 4.0.6
// 数据库: mysql 3.23.41
// 制作: [email protected]
// 完成: 2001-9-17 17:50
// 备注: 此程序中的翻页算法通用于所有数据库
// 更换数据库只需更换php数据库函数
// 需要自己定制的变量注释后面有" * "
// Copyright By 开花石头 ◎ 2001
//*********************************************
mysql_connect('localhost','root','');
mysql_select_db('cngift');//所操作的表名*
$table_name = "cngift_test";//处理删除程序
if(isset($cngift[0])){
for($i = 0;$i<sizeof($cngift);$i++){ $Del_Sql = "Delete from ".$table_name." where ".$sign_value."='$cngift[$i]'";
mysql_query($Del_Sql);
}
echo "<script>alert('共删除了".$i."条数据!')</script>";
}//显示列表数目*
$NUM_OF_1_PAGE = 2;
$num_of_pages = 0 ;
$current_page = 0;
//定义列表的表头(注:$table_title和table_value的顺序一定不能错)*
$table_title = array("编号","品名","单价");//定义列表显示内容的数据库字段名(注:select的值不一定都要显示)*
$table_value = array("id","name","money");//定义显示列表的sql语句,倒叙不要写在这里,后面设定*
$sql = "select id,name,money from cngift_test";//当需要倒叙显示数据时请填写倒叙的数据库字段*
$flashback = "id";//定义sql语句中where后面的条件语句,字串中不需要写where*
//当需要id='$id'时,直接写$where = "id='$id'"*
$where = "name like '%test%'";//定义select中的条件变量作为计算翻页时的传递变量*
//如果$where = "id='$id' and name='$name'"*
//则$impress = "id='$id'&&name='$name'";*
$impress = "";//定义进行数据操作中的参数值,一定是sql中取到的有唯一值的字段*
$sign_value = "id";//处理一般列表
if($where != ""){
$sql = "select * from ".$table_name." where ".$where;
}//处理搜索
if($search_select != ""&&$search_value != ""){
$sql = "select * from ".$table_name." where ".$search_select." like '%".$search_value."%'";
if($where != ""){
$sql = "select * from ".$table_name." where ".$where." and ".$search_select." like '%".$search_value."%'";
}}//处理sql语句倒叙
if($flashback != ""){
$sql.= " order by ".$flashback." desc";
}
$query = mysql_query($sql);
//翻页处理程序
$num_of_rows=mysql_num_rows($query);//设置起始位置
if(!$start_num){$start_num=0;}
($num_of_rows - $start_num)>$NUM_OF_1_PAGE? $num_of_rows_on_current_page =$NUM_OF_1_PAGE:$num_of_rows_on_current_page = $num_of_rows - $start_num;
$next_page = $start_num + $NUM_OF_1_PAGE;
$previous_page = $start_num - $NUM_OF_1_PAGE;if($next_page>=$num_of_rows){$next_page=$start_num;}
if($previous_page<=0) {$previous_page=0;}$last_page = $num_of_rows%$NUM_OF_1_PAGE;
if($last_page==0){$last_page = $num_of_rows - $NUM_OF_1_PAGE;}
else{$last_page = $num_of_rows - $last_page;}
//所有的页
$num_of_pages = (int)($num_of_rows/$NUM_OF_1_PAGE) ;
if($num_of_rows%$NUM_OF_1_PAGE !=0 ) $num_of_pages++;
//当前页
$current_page = (int)($start_num / $NUM_OF_1_PAGE) +1 ;
if($start_num % $NUM_OF_1_PAGE !=0) $current_page ++;$table_title_num = sizeof($table_title);
$table_value_num = sizeof($table_value);
?><html>
<head>
<title>数据操作程序 v 1.0</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
function SelectAll(){
var items = document.cngift.elements[0];
for(var i=0;i<document.cngift.elements.length;i++){
if(document.cngift.elements[i].type != "checkbox"){
continue;}
items = document.cngift.elements[i];
if(items.name = 'cngift[]')
items.checked = true;
}
}
function doSelect(frm)
{
if(frm.c.checked == "")
{
frm.a.readOnly = true;
}else{frm.a.readOnly = false;}
}
</Script>
</head><body bgcolor="#FFFFFF">
<form method="post" action=<?=$PHP_SELF?> name="cngift">
<table width="350" border="1" bordercolorlight="#000000" bordercolordark="#FFFFFF" cellpadding="0" cellspacing="0">
<tr>
<?php
//表头处理
for($i=0;$i<$table_title_num;$i++){
?>
<td height="20">
<div align="center"><font size="2"><?=$table_title[$i]?></font></div>
</td>
<?}?>
<td height="20">
<div align="center"><font size="2">维护操作</font></div>
</td>
<tr>
<?php
@mysql_data_seek($query,$start_num);
for($j=0;$j<$num_of_rows_on_current_page;$j++)
{
//内容列表
$rs = mysql_fetch_array($query);
for($i=0;$i<$table_value_num;$i++){
?>
<td height="20">
<div align="center"><font size="2"><?=$rs[$i]?></font></div>
</td>
<?php
}//for end
?>
<td>
<div align="center"> <font size="2">
<input type="checkbox" name="cngift[]" value=<?=$rs[$sign_value]?>>
</font></div>
</td>
</tr>
<?php
}//for end
?> <tr>
<td colspan="4">
<div align="center">
<input type="hidden" name="start_num" value=<?=$start_num?>>
<input type="hidden" name="sign_value" value=<?=$sign_value?>>
<input type="hidden" name="search_value" value=<?=$search_value?>>
<input type="hidden" name="search_select" value=<?=$search_select?>>
<input type="submit" name="Submit" value="删除" onClick="return confirm('你真的要删除所选信息?!');">
<input type=button value=全选 onClick='SelectAll()'>
<input type=reset value=全不选>
<input type=button value=版权信息 onClick="return confirm('数据操作程序 v 1.0\n\nCopyright By 开花石头 ◎ 2001\n\nEmail:[email protected]');">
</div>
</td>
</tr>
<tr>
<td colspan="4">
<div align="center"><font size="2">|
<?if($current_page != 1){echo "<a href=$PHP_SELF?start_num=0&&search_select=$search_select&&search_value=$search_value&&$impress>";}?>首页</a>
<?if($current_page != 1){echo "<a href=$PHP_SELF?start_num=$previous_page&&search_select=$search_select&&search_value=$search_value&&$impress>";}?>上一页</a>
<?if($current_page != $num_of_pages&&$num_of_pages != 0){echo "<a href=$PHP_SELF?start_num=$next_page&&search_select=$search_select&&search_value=$search_value&&$impress>";}?>下一页</a>
<?if($current_page != $num_of_pages&&$num_of_pages != 0){echo "<a href=$PHP_SELF?start_num=$last_page&&search_select=$search_select&&search_value=$search_value&&$impress>";}?>尾页</a>|
</font></div>
</td>
</tr>
</table>
</form>
<form method="post" action="">
<input type="text" name="search_value" size="15">
<select name="search_select" >
<option value="">选择检索类</option>
<?php
for($i=0;$i<$table_title_num;$i++){
//显示检索条件
echo"<option value=$table_value[$i]>$table_title[$i]</option>";
}
?>
</select>
<input type="hidden" name="start_num" value="">
<input type="submit" name="Submit" value="检索">
</form>
</html>
<!--
本程序为1.0版本版权信息在转载的时候必须保留,但在使用中悉听尊便,包括个人与企业
如果您发现了本程序功能与设计中的bug,请及时通知
-->
哥们,不错哦!