Re: array in and out

From: Date: Mon, 20 Aug 2001 02:03:22 +0000
Subject: Re: array in and out
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-63440@lists.php.net to get a copy of this message
On Mon, 20 Aug 2001 11:25, Chris Schneck wrote: > Since i have little experience with arrays, and the manuals / readme > files online havent been able to help me, I was wondering if anyone had > any ideas why this code doesnt work? > > // get the keywords from db > $keyquery = ("select fld_keyword_word from tbl_keyword order by > rand()"); > $keyresult = mysql_query($keyquery) or die ("couldnt randomize > words"); > // put them into an array > > while ($keyrow = mysql_fetch_array($keyresult)) > { > $keyword[] = '$keyrow["fld_keyword_word"]'; > } > > // print the keywords with a function > $mykeywords = implode(", ", $keyword); > > function print_keywords() > { > echo ($mykewords); > } What part doesn't work? $keyword[] = '$keyrow["fld_keyword_word"]'; would possibly be better without the single quotes, and I don't se where youe are calling the print_keywords function; which wouldn't work as is because it doesn't have access to the variable $mykeywords either from being passed as a parameter or made available as a global. Also you misspelled $mykeywords in the function :-) -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA If a fly has no wings would you call him a walk?

« previous php.general (#63440) next »