Re: foreach question
| From: | Jason Pruim | Date: | Tue, 29 Jul 2008 19:47:33 +0000 |
| Subject: | Re: foreach question | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-277438@lists.php.net to get a copy of this message | ||
On Jul 29, 2008, at 3:33 PM, Daniel Brown wrote:
On Tue, Jul 29, 2008 at 3:25 PM, Jason Pruim <japruim@raoset.com> wrote:Added that, then changed how I was calling it and it works great now... Thanks for looking... The problem was definitely between the chair and the keyboard on this one.function random($random){You're missing mysql_fetch_array(), mysql_fetch_assoc(), or something of the like. Example: <?php // .... code.... $result = mysql_query($randomQuery); $row = mysql_fetch_array($result); foreach($row as $k => $v) {$randomQuery = "SELECT * FROMcurrentORDER BY Rand() LIMIT 2";$result = mysql_query($randomQuery);$row[] = $result; foreach($row as $key => $value) { $random[$key] = $value; } return $random; }//End of function ?>$random[$k] = $v;} // .... code.... } ?>