Rory_M Posted August 9, 2011 Share Posted August 9, 2011 Can anyone help me with this, every time i echo it out it just returns "Array". $sql = mysql_query("SELECT `W_Name` FROM `weapons` ORDER BY RAND() LIMIT 1"); $found_sql = mysql_fetch_array($sql); echo $found_sql; Thanks for the help in advance. :) Quote Link to comment Share on other sites More sharing options...
Lithium Posted August 9, 2011 Share Posted August 9, 2011 you are not forgetting anything? echo $found_sql['W_Name']; Quote Link to comment Share on other sites More sharing options...
Rory_M Posted August 9, 2011 Author Share Posted August 9, 2011 Oh right i forgot that lol. Quote Link to comment Share on other sites More sharing options...
Dominion Posted August 9, 2011 Share Posted August 9, 2011 Using order by rand() should be avoided. http://jan.kneschke.de/projects/mysql/order-by-rand/ Quote Link to comment Share on other sites More sharing options...
Mufasa Posted August 9, 2011 Share Posted August 9, 2011 also, I find the best way to quickly echo an array to be print_r( $array ) - though there are certainly other options Quote Link to comment Share on other sites More sharing options...
Rory_M Posted August 9, 2011 Author Share Posted August 9, 2011 Thanks Dominion and Mufasa. :) Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted August 10, 2011 Share Posted August 10, 2011 I would personally do it like that: For small table, order by rand is a solution... For bigger tables DO NOT use it instead: "SELECT COUNT(*) FROM MY_TABLE" "SELECT * FROM MY_TABLE LIMT ".rnd($maxrow).",1 Quote Link to comment Share on other sites More sharing options...
Rory_M Posted August 10, 2011 Author Share Posted August 10, 2011 Thanks a_bertrand. :) 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.