php 导入mysql数据到access方法
mysql数据库表sqltable
字段id,name,sex,email
access数据库表accesstable
id,name,sex,email
<?
$connect = mysql_connect("localhost","","");
mysql_select_db("mydatabase");
$sql = "select * from sqltable;
$result = mysql_query($sql};
$connectodbc=odbc_connect("DSN","USERNAME","PASSWORD");
while($row = mysql_fetch_row($result))
{
$sql="insert into accesstable
values($row["id",$row["name",$row["sex"],$row["email"])";
odbc_do($connectodbc,$sql);
}
odbc_close($connectodbc);
mysql_close($conect);
?>
<?php
/**
* 上传文件
* to : uploadBoroughThumb|borough|picture
* to : 函数名|目录分类|图片类型
*
*/
require('path.inc.php');
$to = $_GET["to"];
$action = $_GET['action'];
if($action==""){
$action = "form";
}
if($action=="doupload"){
echo '<html>';
echo '<head>';
echo '<title>上传成功</title>';
echo "<meta http-equiv="content-type" content="text/html; charset=gb2312">";
echo '</head>';
$store_info = explode('|',$to);
$js_func = $store_info[0];
/* 判断特殊字符 */
if($store_info[1]){
if(!ereg("^[A-Za-z]+$",$store_info[1])){
exit;
}
}
if($store_info[2]){
if(!ereg("^[A-Za-z]+$",$store_info[2])){
exit;
}
}
$upload_conf = require($cfg['path']['conf'].'upload.cfg.php');
$this_config = (array)$upload_conf[$store_info[1]][$store_info[2]];
if(empty($this_config)){
exit;
}
$upload = new UploadFile();//实例化上传对象
//设置可以上传文件的类型
$upload->setAllowFileType($this_config['allowType']);
foreach ($_FILES as $a_file){
if($a_file['error']!=UPLOAD_ERR_NO_FILE) {
try{
$fileName = $upload->upload($a_file,$cfg['path']['root'].'upfile/'.$this_config['originalPath'], 1);
$f_path['url'] = $this_config['originalPath'].$fileName;
$f_path['name'] = $a_file['name'];
$attach_file[] = $f_path;
if(in_array(strtolower(FileSystem::fileExt($f_path['name'])),array('gif','jpeg','jpg','png')) && !$this_config['noResize']){
//先缩略到指定大小
$image = new Image($cfg['path']['root'].'upfile/'.$this_config['originalPath'].$fileName);
$image->resizeImage($this_config['width'],$this_config['height'],$this_config['resizeType']);
$image->save();
//加水印
if($this_config['watermark']){
$image = new Image($cfg['path']['root'].'upfile/'.$this_config['originalPath'].$fileName);
$image->waterMark($this_config['watermarkPic'],$this_config['watermarkPos']);
$image->save();
}
//如果需要再生成缩略图
if($this_config['thumb']){
$image = new Image($cfg['path']['root'].'upfile/'.$this_config['originalPath'].$fileName);
$image->resizeImage($this_config['thumbWidth'],$this_config['thumbHeight'],$this_config['thumbResizeType']);
if($this_config['originalPath']==$this_config['thumbDir']){
//防止存储目录相同时覆盖原有的图片,不存储缩略图直接设置 thumb 属性为空
$image->save(2,$cfg['path']['root'].'upfile/'.$this_config['thumbDir'],'_thumb');
$thumb_path = $this_config['thumbDir'].FileSystem::getBasicName($fileName, false).'_thumb'.FileSystem::fileExt($fileName, true);
}else{
$image->save(1,$cfg['path']['root'].'upfile/'.$this_config['thumbDir']);
$thumb_path = $this_config['thumbDir'].$fileName;
}
}
}
//回传参数
echo "<script>
var parentForm;
if(window.opener){
parentForm = window.opener;
}else{
parentForm = window.parent;
}
parentForm.".$js_func."('".$f_path['url']."','".$f_path['name']."','".$thumb_path."');
</script>";
}catch(Exception $e){
$page->back( $e->getMessage());
}
}else{
echo "<script>
alert('请先浏览文件后点击上传php教程');
history.back();
</script>";
exit;
}
echo "<script>
/*if(window.opener){
window.close();
}else{
history.back();
}*/
history.back();
</script>";
}
echo '</body>';
echo '</html>';
}elseif($action=="form"){
echo '<html>';
echo '<head>';
echo '<title>上传文件</title>';
echo "<meta http-equiv="content-type" content="text/html; charset=gb2312">";
echo '</head>';
echo "<body leftmargin="0" topmargin="0">";
echo "<table cellpadding="2" cellspacing="1" border="0" height="100%" align="left">";
echo "<form action='upload.php?action=doupload&to=".$to."' method='post' enctype='multipart/form-data'>";
echo "<tr ><td valign='middle'>";
echo "<input type='file' name='uploadfile'>";
echo "<input name='submit' type='submit' value='上传'>";
echo "</td></tr>";
echo "</form>";
echo "</table";
echo "</body>";
echo '</html>';
}
?>
if(!isset($_SERVER['REQUEST_URI'])) {
$_SERVER['REQUEST_URI'] = substr($_SERVER['argv'][0],strpos($_SERVER['argv'][0],';') + 1);
}
/*
+-------------------------------------------
+ Fix: Success
+-------------------------------------------
*/
if ($_SERVER['REQUEST_URI']){
/*
+---------------------------------------
+ Check true string
+---------------------------------------
*/
if (strpos(strtolower($urlconf['domains']),'http://') === false){
$URI_CONFIG_LENGTH = strlen($urlconf['domains'].$urlconf['default']) + 1;
$URI_QUESTED_LENGTH = strlen($_SERVER['REQUEST_URI']);
$_SERVER['REQUEST_URI'] = substr($_SERVER['REQUEST_URI'],$URI_CONFIG_LENGTH,($URI_QUESTED_LENGTH - $URI_CONFIG_LENGTH));
}else{
$URI_CONFIG_LENGTH = $urlconf['domains'].$urlconf['default'].'/';
$URI_QUESTED_LENGTH = 'http://'.($_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']).$_SERVER['REQUEST_URI'];
$_SERVER['REQUEST_URI'] = str_replace($URI_CONFIG_LENGTH,'',$URI_QUESTED_LENGTH);
}
$_SERVER['REQUEST_URI'] = str_replace($urlconf['extents'],'',$_SERVER['REQUEST_URI']);
/*
+---------------------------------------
+ Rewrite uri variables
+---------------------------------------
*/
$URI_REQUESTED_VARIABLES = explode('/',$_SERVER['REQUEST_URI']);
if ($URI_REQUESTED_VARIABLES['0']){
$action = $URI_REQUESTED_VARIABLES['0'];
if ($URI_REQUESTED_VARIABLES['1']){
$option = $URI_REQUESTED_VARIABLES['1'];
if ($URI_REQUESTED_VARIABLES['2']){
$extent = $URI_REQUESTED_VARIABLES['2'];
//if ($action == 'display'){
$info = $extent;
//}
if ($URI_REQUESTED_VARIABLES['3']){
$info = $URI_REQUESTED_VARIABLES['3'];
}
}else{
$extent = $info = '';
}
}else{
$option = $extent = $info = '';
}
}else{
$action = $option = $extent = $info = '';
}
}
<?php
$tempquery = mysql_query("select dpb,facejtype from zgy_member_p_d_basic where dpb = '$city' and facejtype like '%$keyword%' ");
$count = mysql_num_rows( $tempquery );
if( $count )
{
$page=isset($_GET['page'])?$_GET['page']:1;
$pagesize=20;
$pagecount=($count % $pagesize)?(int)($count / $pagesize) +1:$count / $pagesize;
$page=($page>$pagecount || $page<1)?$page=1:$page;
$start=$pagesize*($page-1);
$sql = "Select
dpb,
truename,
uid,
sex,
birth,
education,
experience,
facejkind,
facejtype,
id
from
zgy_member_p_d_basic
where
dpb = '$city' and
facejtype like '%$keyword%' group by uid order by id desc limit $start,$pagesize";
$query = mysql_query( $sql ) or die( mysql_error() );
while( $rs = mysql_fetch_array( $query ) )
{
?>
<tr>
<td><a href="/index.php/display/resume/<?=$rs['id']?>.html" class="col-blu" target="_blank"><?=$rs['truename']?></a></td>
<td>
<?
$date = date("Y-m-d");
$date1 = $rs['birth'];
echo sdate($date,$date1);
?> </td>
<td><?= $rs['sex'] ? '男' : '女' ;?></td>
<td><?= $rs['education']?> </td>
<td><?= $rs['experience']?></td>
<td><?= $rs['facejkind']?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="6">
<div class="listPage"><form action="jobs.php?keyword=<?=$keyword?>&city=<?= $city?>" method="get" enctype="application/x-www-form-urlencoded" >总数:<span class="f-red"><?=$count?>/条</span> 每页<?=$pagesize?>条 当前第<span class="f-red"><?=$page?>/<?=$pagecount?></span>页 <a href="jobs.php?keyword=<?=$keyword?>&city=<?= $city?>&page=<?=1?>" class="col-blu"> 首页 </a><a href="jobs.php?keyword=<?=$keyword?>&city=<?= $city?>&page=<?=$page-1;?>" class="col-blu">上一页 </a><span class="col-blu"> <a href="jobs.php?keyword=<?=$keyword?>&city=<?= $city?>&page=<?=$page+1;?>" class="col-blu">下一页 </a></span><a href="#" class="col-blu"><a href="jobs.php?keyword=<?=$keyword?>&city=<?= $city?>&page=<?=$count;?>" class="col-blu">尾页 </a>转到 第
<input name="page" type="text" id="page" size="3" />
<input name="city" type="hidden" value="<?=$city;?>" />
<input name="keyword" type="hidden" value="<?=$keyword;?>" />
页
<input type="submit" name="Submit" value="确定" />
</form>
</div>
</div>
</td>
</tr>
<?
}
else
{
?>
<tr>
<td colspan="6">对不起,您要查找内容暂时不存在!</td>
</tr>
<?php
}
?>
</table>
</div>
echo ccStrLen($str),'<hr>';
echo ccStrLeft($str,3);
function ccStrLeft($str,$len) #从左边截取中英文混合字符串
{
$ascLen=strlen($str); if($ascLen<=$len) return $str;
$hasCC=ereg("[xA1-xFE]",$str); #同上
$hasAsc=ereg("[x01-xA0]",$str);
if(!$hasCC) return substr($str,0,$len);
if(!$hasAsc)
if($len & 0x01) #如果长度是奇数
return substr($str,0,$len+$len-2);
else
return substr($str,0,$len+$len);
$cind=0;$flag=0;
while($cind<$ascLen)
{
if(ord(substr($str,$cind,1))<0xA1) $flag++;
$cind++;
}
if($flag & 0x01)
return substr($str,0,$len);
else
return substr($str,0,$len-1);
}
function ccStrLen($str) #计算中英文混合字符串的长度
{
$ccLen=0;
$ascLen=strlen($str);
$ind=0;
$hasCC=ereg("[xA1-xFE]",$str); #判断是否有汉字
$hasAsc=ereg("[x01-xA0]",$str); #判断是否有ASCII字符
if($hasCC && !$hasAsc) #只有汉字的情况
return strlen($str)/2;
if(!$hasCC && $hasAsc) #只有Ascii字符的情况
return strlen($str);
for($ind=0;$ind<$ascLen;$ind++)
{
if(ord(substr($str,$ind,1))>0xa0)
{
$ccLen++;
$ind++;
}
else
{
$ccLen++;
}
}
return $ccLen;
}
function cs($str)
{
$ccLen=0;
$ascLen=strlen($str);
$ind=0;
for($ind=0;$ind<$ascLen;$ind++)
{
if(ord(substr($str,$ind,1))>0xa0)
{
$ccLen++;
$ind++;
}
else
{
$ccLen++;
}
}
return $ccLen;
}
相关文章
php 中file_get_contents超时问题的解决方法
file_get_contents超时我知道最多的原因就是你机器访问远程机器过慢,导致php脚本超时了,但也有其它很多原因,下面我来总结file_get_contents超时问题的解决方法总结。...2016-11-25- php如何实现抓取网页图片,相较于手动的粘贴复制,使用小程序要方便快捷多了,喜欢编程的人总会喜欢制作一些简单有用的小软件,最近就参考了网上一个php抓取图片代码,封装了一个php远程抓取图片的类,测试了一下,效果还不错分享...2015-10-30
- 相信很多站长都遇到过这样一个问题,访问页面时出现408错误,下面一聚教程网将为大家介绍408错误出现的原因以及408错误的解决办法。 HTTP 408错误出现原因: HTT...2017-01-22
- 下面我们来看一篇关于Android子控件超出父控件的范围显示出来方法,希望这篇文章能够帮助到各位朋友,有碰到此问题的朋友可以进来看看哦。 <RelativeLayout xmlns:an...2016-10-02
- ps软件是现在非常受大家喜欢的一款软件,有着非常不错的使用功能。这次文章就给大家介绍下ps把文字背景变透明的操作方法,喜欢的一起来看看。 1、使用Photoshop软件...2017-07-06
intellij idea快速查看当前类中的所有方法(推荐)
这篇文章主要介绍了intellij idea快速查看当前类中的所有方法,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2020-09-02- 1.在没有设置默认值的情况下: 复制代码 代码如下:SELECT userinfo.id, user_name, role, adm_regionid, region_name , create_timeFROM userinfoLEFT JOIN region ON userinfo.adm_regionid = region.id 结果:...2014-05-31
js导出table数据到excel即导出为EXCEL文档的方法
复制代码 代码如下: <!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 ht...2013-10-13- 批量更新mysql更新语句很简单,更新一条数据的某个字段,一般这样写:复制代码 代码如下:UPDATE mytable SET myfield = 'value' WHERE other_field = 'other_value';如果更新同一字段为同一个值,mysql也很简单,修改下where即...2013-10-04
- ps软件是一款非常不错的图片处理软件,有着非常不错的使用效果。这次文章要给大家介绍的是ps怎么制作倒影,一起来看看设计倒影的方法。 用ps怎么做倒影最终效果̳...2017-07-06
- 本文涉及的主题虽然很基础,在许多人看来属于小伎俩,但在JavaScript基础知识中属于一个综合性的话题。这里会涉及到对象属性的封装、原型、构造函数、闭包以及立即执行表达式等知识。公有方法 公有方法就是能被外部访问...2015-11-08
安卓手机wifi打不开修复教程,安卓手机wifi打不开解决方法
手机wifi打不开?让小编来告诉你如何解决。还不知道的朋友快来看看。 手机wifi是现在生活中最常用的手机功能,但是遇到手机wifi打不开的情况该怎么办呢?如果手机wifi...2016-12-21- 最近想自学PHP ,做了个验证码,但不知道怎么搞的,总出现一个如下图的小红叉,但验证码就是显示不出来,原因如下 未修改之前,出现如下错误; (1)修改步骤如下,原因如下,原因是apache权限没开, (2)点击打开php.int., 搜索extension=ph...2013-10-04
- 单个字符分割 string s="abcdeabcdeabcde"; string[] sArray=s.Split('c'); foreach(string i in sArray) Console.WriteLine(i.ToString()); 输出下面的结果: ab de...2020-06-25
- javascript控制页面控件隐藏显示的两种方法,方法的不同之处在于控件隐藏后是否还在页面上占位 方法一: 复制代码 代码如下: document.all["panelsms"].style.visibility="hidden"; document.all["panelsms"].style.visi...2013-10-13
连接MySql速度慢的解决方法(skip-name-resolve)
最近在Linux服务器上安装MySql5后,本地使用客户端连MySql速度超慢,本地程序连接也超慢。 解决方法:在配置文件my.cnf的[mysqld]下加入skip-name-resolve。原因是默认安装的MySql开启了DNS的反向解析。如果禁用的话就不能...2015-10-21- 本篇文章是对C#方法进行了详细的总结与介绍,需要的朋友参考下...2020-06-25
- 步骤:Window -> PHP -> Editor -> Templates,这里可以设置(增、删、改、导入等)管理你的模板。新建文件注释、函数注释、代码块等模板的实例新建模板,分别输入Name、Description、Patterna)文件注释Name: 3cfileDescriptio...2013-10-04
- EXCEL数据上传到SQL SERVER中的方法需要注意到三点!注意点一:要把EXCEL数据上传到SQL SERVER中必须提前把EXCEL传到服务器上.做法: 在ASP.NET环境中,添加一个FileUpload上传控件后台代码的E.X: 复制代码 代码如下: if...2013-09-23
- mysql锁定单个表的方法 复制代码 代码如下:mysql>lock table userstat read; mysql>unlock tables; 页级的典型代表引擎为BDB。 表级的典型代表引擎为MyISAM,MEMORY以及很久以前的ISAM。 行级的典型代表引擎为INN...2014-05-31