Php 给定的名称和日期不显示任何数据
这是我的桌子 现在我想根据名称(Test)和月份(01)将数据从MySQL检索到android,但没有数据显示。我的php有什么错误吗 我的php代码Php 给定的名称和日期不显示任何数据,php,mysql,mysqli,Php,Mysql,Mysqli,这是我的桌子 现在我想根据名称(Test)和月份(01)将数据从MySQL检索到android,但没有数据显示。我的php有什么错误吗 我的php代码 <?php define('HOST','127.0.0.1:3307'); define('USER','root'); define('PASS',''); define('DB','androiddb'); $con = mysqli_connect(HOST,USER,PASS,DB) or die('una
<?php
define('HOST','127.0.0.1:3307');
define('USER','root');
define('PASS','');
define('DB','androiddb');
$con = mysqli_connect(HOST,USER,PASS,DB) or die('unable to connect');
$name = $_GET['name'];
$month = $_GET['month'];
$sql = "select * from information WHERE name= '". $name."' and month = '".$month."'";
$res = mysqli_query($con,$sql);
$result=array();
while($row=mysqli_fetch_array($res)){
array_push($result,array('id'=>$row[0],'name'=>$row[1],'weather'=>$row[2],'date'=>$row[3],'status'=>$row[4],
'time_in'=>$row[5], 'time_out'=>$row[6]));
}
echo (json_encode(array("result"=>$result)));
mysqli_close($con);
?>
在SQL语句中有一个条件month=…
,但表中没有month列
这应该起作用:
$sql = "select * from information WHERE name= '". $name."' and MONTH(date) = '".$month."'";