我在数据库上有一个字段,名称为Time_message
,我设置此日期的默认值为w, d-m-Y H:i:s
,我想使用BETWEEN创建一些搜索,并且值只显示“dmY”如何我可以在查询中显示它吗?
我把我的代码放在下面..
$date1 = "21-08-2015";
$date2 = "d-m-Y";
$query = mysql_fetch_array(mysql_query("SELECT COUNT(*) as jumlahdata FROM message_complaint WHERE (status_message='".$data['status_message']."') AND (time_message BETWEEN $date1 AND $date2)"));
答案 0 :(得分:0)
您的MySQL
和MySQLi
存在冲突。使用MySQLi
$date1 = "21-08-2015";
$date2 = "d-m-Y";
$message = $data['status_message'];
$query = mysqli_query($con, "SELECT COUNT(*) as jumlahdata FROM message_complaint WHERE (status_message='$message') AND (time_message BETWEEN '$date1' AND '$date2')");
$row = mysqli_fetch_array($query, MYSQLI_ASSOC);
$con
等于mysqli connection