Re: Fw: [PHP] Re: option tags and WHILE

From: Date: Mon, 20 Aug 2001 06:09:00 +0000
Subject: Re: Fw: [PHP] Re: option tags and WHILE
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-63456@lists.php.net to get a copy of this message
On Mon, 20 Aug 2001 15:05, Chris Schneck wrote: > Thanks to CC Zona and David Robley for their help in gettin this code > out. This code is really nice for satisfying search engines. It offers > different page content every time you refresh and if you feel like > spamming, just use print_keywords(); here and there to be more relevant > :) I'll post the code in case anyone else wishes to use it. > > // 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"]; > } > $mykeywords = implode(", ", $keyword); > > // print the keywords with a function > function print_keywords() > { > global $mykeywords; > echo ($mykeywords); > } Oh, is that what you wanted to do? Lets cut the processing down by eliminating the duplication of effort :-) ie get rid of the 'Put it in an array; take it out of an array;print it'. // 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"); // Print the keywords while($row = mysql_fetch_array($result)) { extract $row; echo $fld_keyword_word; } -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA To a cat, "NO!" means "Not while I'm looking."

« previous php.general (#63456) next »