会员数据导入uchome程序实例
<?php
try {
$uc_db = new DataSource(UC_DBHOST , UC_DBUSER , UC_DBPW , UC_DBNAME,
'mysql', true );
$uc_query = new DbQueryForMysql($uc_db);
} catch (DbException $e) {
// 数据库出错处理处
exit('Database support needed');
}
$sql ="select * from 111cn_member ";
$Db = new Db();
$array = $Db->query($Db,0);
foreach( $array as $_v => $value)
{
$data = $Db->query("SELECT * FROM ".UC_DBTABLEPRE."members WHERE
username='".$rs['username']."'");
if($data) {
$ucuserlist .="username:".$rs['username']." email:".$rs
['email']."rn";
} else {
$salt = substr(uniqid(rand()), -6);
$password = md5($rs['passwd'].$salt);
$Db->query("INSERT INTO ".UC_DBTABLEPRE."members SET uid=
'".$rs['id']."', username='".$rs['username']."', password='$password',
email='".$rs['email']."', lastlogintime ='".$rs['last_login']."',
regdate='".$rs['add_time']."', salt='$salt'");
$Db->query("INSERT INTO ".UC_DBTABLEPRE."memberfields SET
uid='".$rs['id']."'");
}
}
exit("用户导入Ucenter完成");
?>
php getimagesize
getimagesize是读取图片相关信息,返回一个具有四个单元的数组。索引 0 包含图像宽度的像素值,索引 1 包含图像高度的像素值。索引 2 是图像类型的标
<?php
$size = getimagesize($filename);
$fp = fopen($filename, "rb");
if ($size && $fp) {
header("Content-type: {$size['mime']}");
fpassthru($fp);
exit;
} else {
// error
}
?>
#2 getimagesize() example
<?php
list($width, $height, $type, $attr) = getimagesize("img/flag.jpg");
echo "<img" width=100% src="img/flag.jpg" $attr alt="getimagesize() example" />";
?>
Example #3 getimagesize (URL)
<?php
$size = getimagesize("http://www.example.com/gifs/logo.gif");
$size = getimagesize("http://www.example.com/gifs/lo%20go.gif");
?>
Example #4 getimagesize() returning IPTC
<?php
$size = getimagesize("testimg.jpg", $info);
if (isset($info["APP13"])) {
$iptc = iptcparse($info["APP13"]);
var_dump($iptc);
}
?>
<?php
include("../inc/inc.php");
islogin();
$Db = new Db(); //此数据库类地址数据库连接类
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>增加城市分类</title>
<!-- at:jimmy email:mailangel123@163.com -->
<LINK href="/themes/default/css/admin.css" rel=stylesheet>
<style type="text/css">
<!--
.STYLE2 {color: #666666}
-->
</style>
</head>
<body>
<table class="table_list" >
<form action="" name="myfm" id="myfm" >
<caption ><font class="red">
{<?=PostGet('cname');?>}</font>地区管理
</caption>
<tr>
<th width="32%">地区名称</th>
<th width="43%">排序位置</th>
<th width="25%"> </th>
</tr>
<?php
$id = PostGet('aid');
if( !is_numeric( $id ) )
{
exit;
}
$query = $Db->query("Select upid,cntitle,orderid,id from cn_loupan_city where upid='$id' order by orderid asc");
if( $Db->rows( $query ) )
{
$row = $Db->fetch( $query ,0);
foreach( $row as $array => $_v )
{
?>
<tr>
<td class="align_c"><label>
<input id="c_<?=$_v[3]?>" type="text" size="30" value="<?=$_v[1]?>" />
</label></td>
<td class="align_c"><label>
<input id="s_<?=$_v[3]?>" type="text" size="20" value="<?=$_v[2]?>" />
</label></td>
<td class="align_c">
<a href="javascript:sava('c_<?=$_v[3]?>','s_<?=$_v[3]?>',<?=$_v[3]?>);">保存</a>|
<a href="javascript:del('<?=$_v[3]?>');">删除</a></td>
</tr>
<?php
}
}
?>
</form>
</table>
<div style="text-align:center; margin:10px;"><a href="citymange.php">返回上一页</a></div>
<script language="javascript" >
function del(id)
{
if( confirm('确认删除此条信息?') )
{
location.href='public.php?action=deletes&id='+id+'&aid=<?=$id?>&cname=<?=PostGet('cname');?>';
}
}
function sava(title,order,id)
{
if( confirm('确认你输入数据无误不喽?') )
{
var cntitle = document.getElementById(title).value;
var orderid = document.getElementById(order).value;
if( "" == cntitle || cntitle.length>30 )
{
alert('地区名称不能为空!');
}
else if( isNaN( orderid ) )
{
alert("排序位置请输入数字!");
}
else
{
location.href="public.php?action=edits&title="+cntitle+"&orderid="+orderid+"&id="+id+"&aid=<?=$id?>&cname=<?=PostGet('cname');?>";
}
}
}
</script>
</body>
</html>
本站原创转载注明 www.111cn.net
php列出数据再用js 删除数据
<?php
include("../inc/inc.php");
islogin();
$Db = new Db();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>增加城市分类</title>
<!-- at:jimmy email:mailangel123@163.com -->
<LINK href="/themes/default/css/admin.css" rel=stylesheet>
<style type="text/css">
<!--
.STYLE2 {color: #666666}
-->
</style>
</head>
<body>
<table class="table_list" >
<form action="" name="myfm" id="myfm" >
<caption ><font class="red">
{<?=PostGet('cname');?>}</font>地区管理
</caption>
<tr>
<th width="32%">地区名称</th>
<th width="43%">排序位置</th>
<th width="25%"> </th>
</tr>
<?php
$id = PostGet('aid');
if( !is_numeric( $id ) )
{
exit;
}
$query = $Db->query("Select upid,cntitle,orderid,id from cn_loupan_city where upid='$id' order by orderid asc");
if( $Db->rows( $query ) )
{
$row = $Db->fetch( $query ,0);
foreach( $row as $array => $_v )
{
?>
<tr>
<td class="align_c"><label>
<input id="c_<?=$_v[3]?>" type="text" size="30" value="<?=$_v[1]?>" />
</label></td>
<td class="align_c"><label>
<input id="s_<?=$_v[3]?>" type="text" size="20" value="<?=$_v[2]?>" />
</label></td>
<td class="align_c">
<a href="javascript:sava('c_<?=$_v[3]?>','s_<?=$_v[3]?>',<?=$_v[3]?>);">保存</a>|
<a href="javascript:del('<?=$_v[3]?>');">删除</a></td>
</tr>
<?php
}
}
?>
</form>
</table>
<div style="text-align:center; margin:10px;"><a href="citymange.php">返回上一页</a></div>
<script language="javascript" >
function del(id)
{
if( confirm('确认删除此条信息?') )
{
location.href='public.php?action=deletes&id='+id+'&aid=<?=$id?>&cname=<?=PostGet('cname');?>';
}
}
function sava(title,order,id)
{
if( confirm('确认你输入数据无误不喽?') )
{
var cntitle = document.getElementById(title).value;
var orderid = document.getElementById(order).value;
if( "" == cntitle || cntitle.length>30 )
{
alert('地区名称不能为空!');
}
else if( isNaN( orderid ) )
{
alert("排序位置请输入数字!");
}
else
{
location.href="public.php?action=edits&title="+cntitle+"&orderid="+orderid+"&id="+id+"&aid=<?=$id?>&cname=<?=PostGet('cname');?>";
}
}
}
</script>
</body>
</html>
public.php
function deletes()
{
$id = PostGet('id');
$aid =PostGet('aid');
$cn = urlencode(PostGet('cname'));
if( !is_numeric( $id ) )
{
exit;
}
else
{
$Db = new Db();
try{
$Db->query("Delete from cn_loupan_city where id='$id'");
MessAge('操作成功','type.php?aid='.$aid.'&cname='.$cn);
}catch( Execption $e){
MessAge('操作失败!');
}
$Db->close();
}
}
本站原创转载注明 www.111cn.net
php 批量增加数据
下面我们是测试一个php批量增加城市的代码以"|"分开哦。
function Addtype()
{
if( $_FILES ){exit;}
$info ='';
$cityname = trim(PostGet('cityname',1));
$citytype = trim(PostGet('citytype',1));
$orderid = trim(PostGet('orderid',1));
if( $cityname ==0 || !is_numeric( $cityname ) )
{
MessAge('请选择城市');
}
elseif(strlen($citytype) <2 )
{
MessAge('输入城市地区');
}
elseif( !is_numeric($orderid ))
{
MessAge('对不起,排序必须是数字哦!');
}
if( strpos($citytype,'|')!=false)
{
$array = explode('|',$citytype);
if( is_array( $array ) )
{
$array = array_filter($array,'filter');
}
}
else
{
$array = $citytype;
}
$Db= new Db();
$d =date("Y-m-d");
if( is_array( $array ) )
{
foreach( $array as $v => $_v )
{
$row = $Db->query("Select * from 111cn_city where upid=$cityname and cntitle='".$_v."'");
if( $Db->rows( $row ) )
{
$info.=$_v.',';
}
else
{
try{
$Db->query("Insert into 111cn_city(cntitle,upid,orderid,createdate)values('$_v',$cityname,'$orderid','$d')");
}catch (Exception $e){
MessAge('操作失败!');
}
}
}
MessAge("增加成功,失败有$info",'addtype.php');
}
else
{
$Query = $Db->query("select * from 111cn_city where upid=$cityname and cntitle='$array'");
if( $Db->rows( $Query ) )
{
MessAge("对不起,你所要增加的城市[$array]己存在数据库了");
}
else
{
try{
$Db->query("Insert into 111cn_city(cntitle,upid,orderid,createdate)values('$array',$cityname,'$orderid','$d')");
MessAge('操作成功','addtype.php');
}catch (Exception $e){
MessAge('失败成功');
}
}
}
}
本站原创转载注明 www.111cn.net