分类 "PHP" 下的文章

switch(grade)
{
case 'A': /注意,这里是冒号:并不是分号;/
printf("85-100
");
break; /每一个case语句后都要跟一个break用来退出switch语句/
case 'B': /每一个case后的常量表达式必须是不同的值以保证分支的唯一性/
printf("70-84
");
break;
case 'C':
printf("60-69
");
break;
case 'D':
printf("<60
");
break;
default:
printf("error!
");
}

实现输入等级,输出分的范围,不可能实现输入分值,输出等级,那样需要用if......else if.....语句

$order=$obj->getRequest('order_num');//获取数据
$tel=$obj->getRequest('mobiletel');
$tg_name=$obj->getRequest('tuangou_name');
$urlpar="order_num=$order&mobiletel=$tel&tuangou_name=$tg_name";
//where数据,增加查询条件
$where='u.id=t.uid';
if ($order!=''){
$where.=" and order_num like '%$order%'";
}
if ($tel!=''){
$where.=" and mobiletel like '%$tel%'";
}
if ($tg_name!=''){
$where.=" and tuangou_name like '%$tg_name%'";
}
//列表显示,实现分页
$page=$obj->getRequest('page');
$pager = $obj->pager ( "u.mobiletel,t.tuangou_name,t.order_num,t.time,t.money",  "user as u,user_tuangou as t", $where, "t.time desc", 15, $page,$urlpar);
?>

$mobile="13512345678"    $msg="你好!欢迎光临*网站!"
public send_emay($mobile, $msg) {
header ( "content-type:text ml;charset=gbk" );
import ( "@.ORG.emaysms.emaysms" );
/ 网关地址/
$gwUrl = 'http://*';

/ 序列号,请通过销售人员获取/
$serialNumber = '';

/ 密码,请通过销售人员获取/
$password = '*';

/登录后所持有的SESSION KEY,即可通过login方法时创建/
$sessionKey = '123456';

/连接超时时间,单位为秒/
$connectTimeOut = 2;

/远程信息读取超时时间,单位为秒/
$readTimeOut = 10;

/*
$proxyhost        可选,代理服务器地址,默认为 false ,则不使用代理服务器
$proxyport        可选,代理服务器端口,默认为 false
$proxyusername    可选,代理服务器用户名,默认为 false
$proxypassword    可选,代理服务器密码,默认为 false
*/
$proxyhost = false;
$proxyport = false;
$proxyusername = false;
$proxypassword = false;

$client = new emaysms ( $gwUrl,  $serialNumber,  $password,  $sessionKey,  $proxyhost,  $proxyport,  $proxyusername,  $proxypassword,
$connectTimeOut, $readTimeOut );
/iconv转码作用/
$statusCode = $client->sendSMS ( $mobile, iconv ( "utf-8", "gbk", $msg ) . iconv ( "utf-8", "gbk", "[**网站]" ) );

return $statusCode;
}

THINKPHP 中关联查询(多表查询)可以使用 table() 方法或和join方法,请看示例:
联合查询
1、原生查询
$sql = 'select p.product_name, z.message as zmessage, z.rdtime, r.message, r.rdtime from wsd_product as p, wsd_product_zixun as z, wsd_product_zixun_reply as r  where p.id = z.lipin_id and z.id = r.zixun_id order by z.rdtime';
$list = $Form->query($sql);
2、join() 两表查询
$list = $Form->join('think_sort ON think_form.sort_id = think_sort.sort_id' )->select();
3、join() 多表查询
$list = $Form->join('think_sort ON think_form.sort_id = think_sort.sort_id' )->join('think_brand ON think_form.brand_id = think_brand.brand_id' )->select();
4、table()
$list = $user->table('user_status stats, user_profile profile')->where('stats.id = profile.typeid')->field('stats.id as id, stats.display as display, profile.title as title,profile.content as content')->order('stats.id desc' )->select();

问题:使用DedeCMS采集的文章有分页,生成页面后内容显示不全。如何去除采集文章中的#p #副标题#e#?如何不让有#p #副标题#e#的文章分页
解决:修改生成页面的代码,include/arc.archives.class.php
方法:
一、打开include/arc.archives.class.php
注释250-277行
//$this->SplitFields = explode("#p #",$this->Fields[$this->SplitPageField]);
//$i = 1;
//foreach($this->SplitFields as $k=>$v)
//{
// $tmpv = cn_substr($v,50);
// $pos = strpos($tmpv,'#e#');
// if($pos>0)
// {
// $st = trim(cn_substr($tmpv,$pos));
// if($st==""||$st=="副标题"||$st=="分页标题")
// {
// $this->SplitFields[$k] = preg_replace("/^(.*)#e#/is","",$v);
// continue;
// }
// else
// {
// $this->SplitFields[$k] = preg_replace("/^(.*)#e#/is","",$v);
// $this->SplitTitles[$k] = $st;
// }
// }
// else
// {
// continue;
// }
// $i++;
//}
//$this->TotalPage = count($this->SplitFields);
//$this->Fields['totalpage'] = $this->TotalPage;
二、从250行开始加上
$this->SplitFields = preg_replace("/^(.*)#e#/","",$this->Fields[$this->SplitPageField]);
$this->SplitFields = preg_replace("/副标题#e#/","",$this->SplitFields);
$this->SplitFields = preg_replace("/#p #(.*)#e#/is","",$this->SplitFields);
三、之后修改691行
$this->Fields[$this->SplitPageField] = $this->SplitFields[$pageNo - 1];

$this->Fields[$this->SplitPageField] = $this->SplitFields;

注:由于显示问题,上面代码中有多余空格