DATABASE Structure:
ID | USERID | ENTRYDATE | EXITDATE | PRICE | ROOMID
-----------------------------------------------------
1 | 2 | 2012-10-1 | 2012-10-4| 100 | 1
2 | 2 | 2012-10-1 | 2012-10-4| 100 | 2
3 | 2 | 2012-10-1 | 2012-10-4| 100 | 3
4 | 2 | 2012-10-6 | 2012-10-9| 100 | 4
5 | 2 | 2012-10-6 | 2012-10-9| 100 | 55
i need some help please. I want to display a set of records from this database. i want to display all those with same USERID, but group those with the same ENTRYDATE and EXITDATE in the same DIV. example, the result should be like this...
我需要一些帮助。我想从这个数据库中显示一组记录。我想显示具有相同USERID的所有那些,但在同一个DIV中对那些具有相同ENTRYDATE和EXITDATE的那些进行分组。例如,结果应该是这样的......
ID | USERID | ENTRYDATE | EXITDATE | PRICE | ROOMID
------------------------------------------------------
1 | 2 | 2012-10-1 | 2012-10-4| 100 | 1
2 | 2 | 2012-10-1 | 2012-10-4| 100 | 2
3 | 2 | 2012-10-1 | 2012-10-4| 100 | 3
ID | USERID | ENTRYDATE | EXITDATE | PRICE | ROOMID
----------------------------------------------------
4 | 2 | 2012-10-6 | 2012-10-9| 100 | 4
5 | 2 | 2012-10-6 | 2012-10-9| 100 | 5
1 个解决方案
#1
0
I am not sure I understand your question correctly. I assume you have a string-indexed array and you want to split it basing on ENTRYDATE and EXITDATE values. Maybe something like this:
我不确定我是否理解你的问题。我假设你有一个字符串索引数组,你想根据ENTRYDATE和EXITDATE值拆分它。也许是这样的:
$currentEntry = $data[0]['ENTRYDATE'];
$currentExit = $data[0]['EXITDATE'];
$splitted = array();
$i = 0;
foreach ($data as $row) {
if ($row['ENTRYDATE'] == $currentEntry && $row['ENTRYDATE'] == $currentExit) {
$splitted[$i] []= $row;
} else {
$currentEntry = $row['ENTRYDATE'];
$currentExit = $row['EXITDATE'];
$i++;
}
}
#1
0
I am not sure I understand your question correctly. I assume you have a string-indexed array and you want to split it basing on ENTRYDATE and EXITDATE values. Maybe something like this:
我不确定我是否理解你的问题。我假设你有一个字符串索引数组,你想根据ENTRYDATE和EXITDATE值拆分它。也许是这样的:
$currentEntry = $data[0]['ENTRYDATE'];
$currentExit = $data[0]['EXITDATE'];
$splitted = array();
$i = 0;
foreach ($data as $row) {
if ($row['ENTRYDATE'] == $currentEntry && $row['ENTRYDATE'] == $currentExit) {
$splitted[$i] []= $row;
} else {
$currentEntry = $row['ENTRYDATE'];
$currentExit = $row['EXITDATE'];
$i++;
}
}