我正在尝试保存到数据库中的数据数组。条件(strtotime($row[date]) == strtotime(date('Y-m-d', $dat)) && $row[id_zadanie] == $tab[$i])
为真,但不是记录零。可能有什么不对?
$query = "SELECT date, time, id_czaspracy, id_zadanie FROM ".$prefix."zadanie_czaspracy WHERE id_pracownik = ".$id_pracownik." order by date ASC";
$news1 = mysql_query($zapytanie) or die ('błąd: ' . mysql_error());
$daty = array();
while ($row = mysql_fetch_array($news1)) {
$ile = 10;
for($index = 0; $index<$ile; ++$index)
{
$dat = mktime(0, 0, 0, 1 , 1+$index, 2013);
$id_date = date('Y-m-d', $dat);
$daty[$id_date] = array('date' => date('Y-m-d', $dat), 'time' => array());
$tab = array(1,2,3,4,5);
$n = count($tab);
for ($i=0;$i<$n; $i++) {
if(strtotime($row[date]) == strtotime(date('Y-m-d', $dat)) && $row[id_zadanie] == $tab[$i]) {
echo 'Id_zad:'.$row[id_zadanie].' Time:'.$row[time].' Data:'.strtotime($row[date]).' Str: '.strtotime(date('Y-m-d', $dat)).'<br/>';
$daty[$id_date]['time'][] = array('time' => $row['time']); // DONT WORK
} else {
$daty[$id_date]['time'][] = array('time' => 0);
}
}
}
}
阵列:
Array
(
[2013-01-01] => Array
(
[date] => 2013-01-01
[czas] => Array
(
[0] => Array
(
[czas] => 0
)
[1] => Array
(
[czas] => 0
)
[2] => Array
(
[czas] => 0
)
[3] => Array
(
[czas] => 0
)
[4] => Array
(
[czas] => 0
)
)
)
[2013-01-02] => Array
...
查询结果:
Id_zad:5 Czas:5 Data:1356994800 Str: 1356994800
Id_zad:4 Czas:6 Data:1356994800 Str: 1356994800
Id_zad:3 Czas:4 Data:1357081200 Str: 1357081200
Id_zad:4 Czas:8 Data:1357081200 Str: 1357081200
Id_zad:4 Czas:8 Data:1357167600 Str: 1357167600