好久没写原生的PHP代码调用数据库了

eader("Content-type: text/html; charset=utf-8");
$time=$symptoms=$attr=0; $symptoms=$_POST['symptoms'];
!empty($symptoms) && sort($symptoms);
$time=$_POST['time']; $attr=$_POST['attr'];
//$json_string=file_get_contents('data.json');
//$data = json_decode($json_string, true);
//$dataAry=$data['sites'];
if(is_array($attr)) {
$attr=implode(',',$attr);
} $conn=mysqli_connect("127.0.0.1",'bc',"1111",'test'); $res=$data=$final=array();
$count=0;
$tmp='';
!empty($symptoms) && $tmp=implode(',',$symptoms); function getAttr($conn,$id) {
$res='';
$sql="select * from h_attr where id=".$id;
$result=mysqli_query($conn,$sql);
if($result) {
$dinfo=mysqli_fetch_array($result);
$res=$dinfo['name'];
}
return $res;
} function getSymptoms($conn,$id) {
$res=array();
$sql="select * from h_symptom where id in (".$id.")"; $result=mysqli_query($conn,$sql); $dinfo=mysqli_fetch_all($result);
foreach($dinfo as $k=>$v) {
$res[]=$v[3];
}
$res=implode("+",$res);
return $res;
} $count=0;
if($time==1 ) {
$sql="select * from h_usage where attr=".$attr;
$time&& $sql=$sql." and time =".$time;
$tmp&& $sql=$sql." and symptom in('".$tmp."')";
} if($time==2) {
$sql="select * from h_usage where 1=1 ";
$time&& $sql=$sql." and time=".$time;
$tmp&& $sql=$sql." and symptom in('".$tmp."')";
} $result=mysqli_query($conn,$sql); if($result) {
$dinfo=mysqli_fetch_all($result); foreach($dinfo as $k=>$v) {
$res[$k]['answer']=$v[3];
$res[$k]['name']=getSymptoms($conn,$v[5]);
$res[$k]['zhengzhuang']=getAttr($conn,$attr);
$count++; }
}
//$final[$k]=$res; $data['data']=$res;
$data['count']=$count;
echo json_encode($data);

好久没写原生的PHP调用数据库代码了分享个的更多相关文章

  1. 好久没写Blog了

    上一年的经历: <炸年兽>搞了一阵后,美术去创业了.. 和另一个美术断断续续,做了个<斗战圣佛>,挺山寨的,都没敢跟别人说. 不管怎么说也算是自己上了一个appStore的游戏 ...

  2. 好久没写了,总结一下lnux常用的命令(基础)

    Linux 1.init 0 关机 2.init 6  重启 3.ls 列出当前目录下的文件 4.cd  切换目录  cd -  切换最近使用的两次目录 5.pwd 查看当前所在的路径 (“-”为用户 ...

  3. 好久没写作业了,因为组里分配了任务,学习了Resnet和DenseNet,把概要po上来和大家分享。

    Res: 学长说,不要看别人的博客.看多了就看傻了!俗话说,不听老人言,吃亏在眼前. 第一篇论文来咯!Deep Residual Learning for Image Recognition!国人写的 ...

  4. 利用border和伪类画出三角形 ps:好久没写博客了。。。

    有一个半月没有写博客了,这段时间,小哥我经历了自入行前端最为黑暗的时期,迷茫,空虚,不想写代码,不想做研究了.连打游戏都没有兴趣,如同行尸走肉一般.还好,毕业论文的初稿完成后,整个时间段最恶心最难熬的 ...

  5. c++设计模式总结 好久没写博客了 实在是忙

    具体代码就不贴出来了   通俗易懂的理解方式      原创 c++设计模式: 简单工厂模式 工厂模式有一种非常形象的描述,建立对象的类就如一个工厂,而需要被建立的对象就是一个个产品:在工厂中加工产品 ...

  6. python io 模块之 open() 方法(好久没写博客了)

    io.open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True),打开file ...

  7. 好久没写blog了 ~ 换了个城市,换了个公司,各种忙碌

    最近一直在忙工作交接以及换城市.入职的事情 ~~~ 新公司做C++的比较少,so全上C++11了,写代码各种爽. 最近应该会写一点关于QT的blog , 学到新知识了哈.

  8. 好久好久没写,,百度API逆地址解析以及删除指定marker

    百度地图Api中 除覆盖物有两个方法:map.removeOverlay()或者 map.clearOverlays(),其中 clearOverlays()方法一次移除所有的覆盖物removeOve ...

  9. 好久没写了,SQLSERVER服务丢失后怎么办

    服务器突然中了病毒,查杀后,结果两个服务也丢了, 从其他机器上COPY了两个EXE过来,编写这两个服务就搞定了,不用重装MSSQL2005了 sc create MSSQLSERVER binpath ...

随机推荐

  1. openssl生成随机数

    #include <stdio.h> #include <openssl/bn.h> int main() { BIGNUM *bn; bn = BN_new(); //生成一 ...

  2. idea加载springboot 项目热加载失效

    需要打开 help -> find action ->registry ->其中的compiler.automake.allow.when.app.running勾上

  3. Delphi-基础(for循环)

    1.判断0~10之间,当循环I=3时候跳出当前循环,当I等于8时候,退出当前循环. procedure Countand(); var I: Integer; begin do begin Write ...

  4. 程序员代码面试指南 IT名企算法与数据结构题目最优解

    原文链接 这是一本程序员面试宝典!书中对IT名企代码面试各类题目的最优解进行了总结,并提供了相关代码实现.针对当前程序员面试缺乏权威题目汇总这一痛点,本书选取将近200道真实出现过的经典代码面试题,帮 ...

  5. 洛谷 P5564: [Celeste-B]Say Goodbye

    题目传送门:洛谷 P5564. 题意简述: 有 \(n\) 个点,染 \(m\) 种颜色,第 \(i\) 种颜色染恰好 \(cnt_i\) 个节点,满足 \(cnt_1+cnt_2+\cdots+cn ...

  6. python cookie登录DVWA,phpstudy搭建DVWA参考https://www.jianshu.com/p/97d874548300

    import requestsheader={"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleW ...

  7. E07【餐厅】What would you recommend?

    核心句型 What would you recommend? 你有什么推荐吗? 场景对话: A:What do  you  want  to  eat? 你想吃点什么? B:I don't know. ...

  8. 生产者和消费者模型producer and consumer(单线程下实现高并发)

    #1.生产者和消费者模型producer and consumer modelimport timedef producer(): ret = [] for i in range(2): time.s ...

  9. iptables防火墙的基本应用

    iptables是Linux上常用的防火墙软件,下面说一下iptables的安装.清除iptables规则.iptables只开放指定端口.iptables屏蔽指定ip.ip段及解封.删除已添加的ip ...

  10. Machine Learning in Finance – Present and Future Applications

    https://emerj.com/ai-sector-overviews/machine-learning-in-finance/ Machine learning has had fruitful ...