php access 数据连接与读取保存编辑数据

php教程 access 数据连接与读取保存数据解析

$conn = new com("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("php教程");
//与access连接要用到com接口了。
$conn->Open($connstr);
$rs = new com("ADODB.RecordSet");
//数据查询并显示出来
$rs->Open("select * from szd_t",$conn,1,1);
while(! $rs->eof) {
 $f = $rs->Fields(1);
 echo $f->value;
 $rs->MoveNext();
}

阅读全文

php给图片加水印与上传图片加水印php类

php教程给图片加水印与上传图片加水印php类


/*
* 功能:PHP图片水印 (水印支持图片或文字)
* 参数:
* $groundImage 背景图片,即需要加水印的图片,暂只支持GIF,JPG,PNG格式;
* $waterPos 水印位置,有10种状态,0为随机位置;
* 1为顶端居左,2为顶端居中,3为顶端居右;
* 4为中部居左,5为中部居中,6为中部居右;
* 7为底端居左,8为底端居中,9为底端居右;
* $waterImage 图片水印,即作为水印的图片,暂只支持GIF,JPG,PNG格式;
* $waterText 文字水印,即把文字作为为水印,支持ASCII码,不支持中文;
* $textFont 文字大小,值为1、2、3、4或5,默认为5;
* $textColor 文字颜色,值为十六进制颜色值,默认为#FF0000(红色);
*
* 注意:Support GD 2.0,Support FreeType、GIF Read、GIF Create、JPG 、PNG
* $waterImage 和 $waterText 最好不要同时使用,选其中之一即可,优先使用 $waterImage。
* 当$waterImage有效时,参数$waterString、$stringFont、$stringColor均不生效。
* 加水印后的图片的文件名和 $groundImage 一样。
* 作者:longware @ 2004-11-3 14:15:13
*/
function imageWaterMark($groundImage,$waterPos=0,$waterImage=”",$waterText=”",$textFont=5,$textColor=”#FF0000″)
{
$isWaterImage = FALSE;
$formatMsg = “暂不支持该文件格式,请用图片处理软件将图片转换为GIF、JPG、PNG格式。”;

阅读全文

php 生成缩略图程序

php教程 生成缩略图程序
function ResizeImage($im,$maxwidth,$maxheight,$name){
$width = imagesx($im);
$height = imagesy($im);
if(($maxwidth && $width > $maxwidth) || ($maxheight && $height > $maxheight)){
if($maxwidth && $width > $maxwidth){
$widthratio = $maxwidth/$width;
$RESIZEWIDTH=true;
}
if($maxheight && $height > $maxheight){
$heightratio = $maxheight/$height;
$RESIZEHEIGHT=true;
}
if($RESIZEWIDTH && $RESIZEHEIGHT){
if($widthratio < $heightratio){
$ratio = $widthratio;
}else{
$ratio = $heightratio;
}
}elseif($RESIZEWIDTH){
$ratio = $widthratio;
}elseif($RESIZEHEIGHT){
$ratio = $heightratio;
}
$newwidth = $width * $ratio;
$newheight = $height * $ratio;
if(function_exists("imagecopyresampled")){
$newim = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
}else{
$newim = imagecreate($newwidth, $newheight);
imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
}
ImageJpeg ($newim,$smalladdrname.$name.".jpg");
ImageDestroy ($newim);
}else{
ImageJpeg ($im,$smalladdrname.$name.".jpg");
}
}

阅读全文

php按指定大小等比缩放生成上传图片缩略图

php教程按指定大小等比缩放生成上传图片缩略图
/**
 * *
 *等比缩放
 * @param unknown_type $srcImage   源图片路径
 * @param unknown_type $toFile     目标图片路径
 * @param unknown_type $maxWidth   最大宽
 * @param unknown_type $maxHeight  最大高
 * @param unknown_type $imgQuality 图片质量
 * @return unknown
 */

阅读全文

php 中文与英文验证码程序代码

php教程 中文与英文验证码程序代码

//英文验证码相对简单,不要作hex处理,直接用色彩值就OK了。如果
session_start();
function rand_create()
{
    //通知浏览器将要输出PNG图片
    Header("Content-type: image/PNG");
    //准备好随机数发生器种子 
    srand((double)microtime()*1000000);
    //准备图片的相关参数  
    $im = imagecreate(62,22);
    $black = ImageColorAllocate($im, 0,0,0);  //RGB黑色标识符
    $white = ImageColorAllocate($im, 255,255,255); //RGB白色标识符
    $gray = ImageColorAllocate($im, 200,200,200); //RGB灰色标识符
    //开始作图    
    imagefill($im,0,0,$gray);
    while(($randval=rand()%100000)<10000);{
        $_SESSION["Auth_code"] = $randval;
        //将四位整数验证码绘入图片 
        imagestring($im, 5, 10, 3, $randval, $black);
    }
    //加入干扰象素   
    for($i=0;$i<200;$i++){
        $randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
        imagesetpixel($im, rand()%70 , rand()%30 , $randcolor);
    }
    //输出验证图片
    ImagePNG($im);
    //销毁图像标识符
    ImageDestroy($im);
}
rand_create();

阅读全文

本人原创php通用翻页类,支持上*页和下*页..

function fPageCount($TotalResult,$numPerPage,$Page){
    $NaviLength=10 ; //显示数量
    $showMorePageGo_Type_=0; //跳转样式
    $int_showNumberLink_=十;
    $nonLinkColor_="#999999";
    $toF_="<font face=webdings title=首页>9</font>" ;
    $toP10_=" <font face=webdings title=上十页>7</font>";
    $toP1_=" <font face=webdings title=上一页>3</font>";
    $toN1_=" <font face=webdings title=下一页>4</font>";
    $toN10_=" <font face=webdings title=下十页>8</font>";
    $toL_="<font face=webdings title=最后一页>:</font>";
    $page_index = "";

    $tpagecount = ceil($TotalResult/$numPerPage);
$nowCoolPage=ceil($Page/$NaviLength);
    $toPage_ = $_SERVER[QUERY_STRING];
    if ( $toPage_ == ) {
       $toPage_ = "?page=";本人原创php通用翻页类,支持上*页和下*页..
    }else {
       $toPage_ = preg_replace("/&?page=d+/", , $toPage_);
       $toPage_ = "?".$toPage_."&page=";
    }
     
if($nowCoolPage == 1){
        $page_index.="<font color=".$nonLinkColor_." title=首页>".$toF_."</font> ";
        $page_index.="<font color=".$nonLinkColor_." title=上".$int_showNumberLink_."页>".$toP10_."</font> ";
    }else{
        $preRow =  $Page-$NaviLength;
  $page_index.="<a href=".$toPage_."1 title=首页>".$toF_."</a> ";
  $page_index.="<a href=".$toPage_.$preRow." title=上".$int_showNumberLink_."页>".$toP10_."</a> ";
    }
    $upRow   = $Page-1;
    $downRow = $Page+1;
    if ($upRow>0){
       $page_index.="<a href=".$toPage_.$upRow." title=上一页>".$toP1_."</a> ";
    }else{
       $page_index.="<font color=".$nonLinkColor_." title=上一页>".$toP1_."</font> ";
    }
     
for($i=1;$i<=$NaviLength;$i++){
         $nowPage=($nowCoolPage-1)*$NaviLength+$i;
         if($nowPage!=$Page){
             if($nowPage<=$tpagecount){
                 $page_index.="  <a href=".$toPage_.$nowPage.">" .$nowPage. "</a> ";
             }else{
                 break;
             }
         }else{
             if($tpagecount != 1){
                $page_index.="<b>".$nowPage."</b>";
             }
         }
      }
     if ($downRow <= $tpagecount){
         $page_index.="<a href=".$toPage_.$downRow." title=下一页>".$toN1_."</a> ";
     }else{
         $page_index.="<font color=".$nonLinkColor_." title=下一页>".$toN1_."</font> ";
     }
     if($nowCoolPage == $tpagecount){
         $page_index.=" <font color=".$nonLinkColor_." title=下".$int_showNumberLink_."页>".$toN10_."</font> ";
         $page_index.="<font color=".$nonLinkColor_." title=尾页>".$toL_."</font>";
     }else{
         $nextRow = $Page+$NaviLength;
         $theEndRow = $tpagecount;
         $page_index.=" <a href=".$toPage_.$nextRow." title=下".$int_showNumberLink_."页>".$toN10_."</a> ";
         $page_index.="<a href=".$toPage_.$theEndRow." title=尾页>".$toL_."</a>";
     }
    if ($showMorePageGo_Type_ ==1){
      $Show_Page_i = $Page + 1 ;
    if ($Show_Page_i>$tpagecount) $Show_Page_i = 1;
    $page_index.="  跳转<input type=text id=skip value= onkeyup=this.value=this.value.replace(/[^d]+/,) style=width:40px/>  <input type=button value=确定 class=btn onclick=location.href=?page=+$(skip).value+".$toPage_.";/>n";
       }else{
       $page_index.=" 跳转:<select name=select size=1 style=font-size: 12px onchange=php教程?name=javascript教程>javascript:window.location.href=this.options[this.selectedIndex].value>";
     for($i=1;$i<=$tpagecount;$i++){
     if($Page==$i){
        $selected=" selected";
     }else{
        $selected="";
        }
        $page_index.=" <option value=".$toPage_.$i;
        $page_index.=$selected." style=color:#FF0000";
        $page_index.=">第".$i."页</option>";
     }
        $page_index.="</select>";
   }
        $page_index.=$p_.$sp2_."  每页<b>".$numPerPage."</b>个记录,现在是:<b><span class=tx>".$sp2_.$Page."</span>/".$tpagecount."</b>页,共<b><span id=recordcount>".$sp2_.$TotalResult."</span></b>个记录。";
    return $page_index;
}


例子:<?php echo fPageCount($TotalResult,$numPerPage,$page)?>   $TotalResult 代表总数 $numPerPage 每页显示数量 $page 页码

阅读全文