body {background-color: #c3c3c3}

php 总结(11)php常用整理

 展示类:
时间戳转换时间       echo '<td>'.date("Y-m-d", $a['addtime']).'</td>';
判断种类 输出颜色   echo "<tr";if ($a['jiedai']) {  echo " style='background:#1E9FFF;color:white'"; } echo ">" ;
 截取字符串输出 substr($arr['content'],0,10);
编码 header("Content-type:text/html;charset=utf-8");  

展示图片    header('content-type:image/jpeg');

 模糊查询:select * from patient_18 WHERE  name like  '%美%'

综合模糊:SELECT * FROM patient_18 WHERE CONCAT(`name`,qq,tel,author) LIKE "%8639%"

多次查询     

$where = array();
$where[] = "a>1";
$searchword='z航三';
if ($searchword) {
	$where[] = "(binary t.name like '%{$searchword}%')";
}
$sqlwhere = count($where) > 0 ? ("where ".implode(" and ", $where)) : "";
echo "$sqlwhere";

  

 

 

 

万年历

<?php 
// 判断年份
$years=$_GET['y']?$_GET['y']:date('Y');
// 判断月份
$month=$_GET['m']?$_GET['m']:date('m');


// 判断上个月
$prevyear=$years;
$prevmonth=$month-1;
if ($prevmonth<1) {
 $prevmonth=12;
$prevyear=$years-1;
}
// 判断下个月
$nextyear=$years;
$nextmonth=$month+1;
if ($nextmonth>12) {
 $nextmonth=1;
$nextyear=$years+1;
}


// 获取当前月1号时间戳
$firstday=strtotime("{$years}-{$month}-1");
// echo "$firstday";
// 判断月份天数
$days=date('t',$firstday);

// 判断周几
$week=date('w',$firstday);
// $week=date('w');
// echo "<br>";
// echo "$week";

 模糊 

posted @ 2019-03-12 13:53  最美胡萝卜  阅读(170)  评论(0编辑  收藏  举报
body {background-color: #c3c3c3}