phpretard Posted March 24, 2009 Share Posted March 24, 2009 I am trying to combine 2 words from a row called key. The row key has 20 entries and all are different words. For example one word in row key is "Green" Anthoer is "Spoon". On a random basis I would like to echo "GreenSpoon" // or any other combination of words The code below only works on one page by itself. I need to include it in another page and when I do it only echos 1 word. <? include ("../db.php"); $EmailKey=mysql_query("SELECT * FROM emailkeys ORDER BY RAND() limit 2"); if (!$EmailKey){die(mysql_error());} WHILE ($row=mysql_fetch_array($EmailKey)){ $key1=$row['key']; echo $key1; } mysql_close($con); ?> Thank you! Quote Link to comment Share on other sites More sharing options...
trq Posted March 24, 2009 Share Posted March 24, 2009 $key1 .= $row['key']; Quote Link to comment Share on other sites More sharing options...
phpretard Posted March 24, 2009 Author Share Posted March 24, 2009 Why does that work because of a freekin dot???? Quote Link to comment Share on other sites More sharing options...
trq Posted March 24, 2009 Share Posted March 24, 2009 Because otherwise you simply overiding $key1 with a new word each iteration of your loop. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted March 24, 2009 Share Posted March 24, 2009 LOL .= is short for "add onto" So, $a=$a.' this is added onto the end'; is the same as $a.=' this is added onto the end'; Quote Link to comment Share on other sites More sharing options...
phpretard Posted March 24, 2009 Author Share Posted March 24, 2009 Thank you! That was painful. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.