Re: Date/time format?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2007. 03. 30, péntek keltezéssel 14.00-kor Jason Pruim ezt írta:
> On Mar 29, 2007, at 4:52 PM, Zoltán Németh wrote:
> 
> >
> 
> <snip>
> >
> > (I assume you want this calculation within one given day)
> > you could read all rows into an array like
> >
> > $timeinfo = array();
> > $sql = "SELECT minute, sequence FROM table WHERE day='$day'";
> > $result = mysql_query($result);
> > while ($row = mysql_fetch_assoc($result)) {
> > 	$timeinfo[$row['sequence'] = $row['minute'];
> > }
> >
> > and then calculate and echo the difference between any element of the
> > array:
> >
> > $diff0_1 = $timeinfo[1] - $timeinfo[0];
> >
> 
> $timeinfo[$row['sequence'] = $row['minute']; <--- is the "[" between  
> $timeinfo and $row a typo? or is there supposed to be a closing "]"  
> somewhere?

yeah it should be closed, sorry for the typo.
this way:

$timeinfo[$row['sequence']] = $row['minute'];

greets
Zoltán Németh

> 
> When I add a closing "]" to it as such:
> 
> $timeinfo[$row['sequence'] = $row['minute']];
> 
> I get this error when I try and open the page:
> [Fri Mar 30 13:55:36 2007] [error] PHP Notice:  Undefined index:   
> minute in /Volumes/RAIDer/webserver/Documents/tests/oatstest/ 
> oatstime.php on line 15
> [Fri Mar 30 13:55:36 2007] [error] PHP Notice:  Undefined index:    
> in /Volumes/RAIDer/webserver/Documents/tests/oatstest/oatstime.php on  
> line 15
> [Fri Mar 30 13:55:36 2007] [error] PHP Notice:  Undefined offset:  1  
> in /Volumes/RAIDer/webserver/Documents/tests/oatstest/oatstime.php on  
> line 18
> [Fri Mar 30 13:55:36 2007] [error] PHP Notice:  Undefined offset:  0  
> in /Volumes/RAIDer/webserver/Documents/tests/oatstest/oatstime.php on  
> line 18
> 
> Line 15 is this line:
> 
> $timeinfo[$row['sequence'] = $row['minute']];
> 
> and line 18 has:
> 
> $diff0_1 = $timeinfo[1] - $timeinfo[0];
> 
> What I am trying to do is subtract $timeinfo[1] from $timeinfo[0] and  
> then display the difference.
> 
> When I echo $timeinfo it just says "array" so my thinking is that the  
> errors are caused by the array not being populated properly based on  
> the extra "[" or a missing "]". Am I at least on the right track?
> 
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux