Re: Fwd: Re: need help with foreach()

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

 



On Monday 10 March 2003 17:56, David Rice wrote:
> Here is the complete function I am using.
> I returned, for testing i commented out the foreach loop and returned
> $staff, then $tips.... both arrays returned NULL when i did a
> var_dump(pointvalue($startdate));

I haven't been following this thread so I'm not sure what your objective is. 
But ...


> function pointvalue($start){
> 	$query = "SELECT * FROM Tips WHERE date >= $start and date <= ($start +
> INTERVAL 6 DAY) ";
> 	$result = mysql_query($query);
> 	while($row = mysql_fetch_array($result)){
> 	$date = $row[Date];

You should really be using:

   $date = $row['Date'];

Also what is $date supposed to be storing? Each iteration of the while-loop 
it's being overwritten with the 'latest' date.

> 		$tips[$date] = $row[TotalTips];

As above you should put single-quotes around your array subscripts.

> 	}
> 	$query = "SELECT * FROM Rota WHERE date >= $start and date <= ($start +
> INTERVAL 6 DAY) ";
> 	$result = mysql_query($query);
> 	while ($row = mysql_fetch_array($result)){
> 		$date = $row[Date];

Again, see above comments.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
------------------------------------------
/*
You can observe a lot just by watching.  -- Yogi Berra
*/


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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux