Re: Fwd: Re: [PHP-DB] need help with foreach()

From: Date: Mon, 10 Mar 2003 11:27:46 +0000
Subject: Re: Fwd: Re: [PHP-DB] need help with foreach()
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-26228@lists.php.net to get a copy of this message
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 */

« previous php.db (#26228) next »