Rdogg112 Posted March 30, 2009 Share Posted March 30, 2009 im making a game and i need to show a users money but i dont know how help? Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted March 30, 2009 Share Posted March 30, 2009 You should probably learn to program before trying to code a game. Quote Link to comment Share on other sites More sharing options...
Rdogg112 Posted March 30, 2009 Author Share Posted March 30, 2009 true this is wat i got so far $sql = mysql_query("SELECT * FROM `users` WHERE `money` = $money") or die(mysql_error()); $blah = mysql_fetch_array($sql); echo 'Money: '. $blah['money']; but i dont know what to put in $money + i dont know if that code works. Quote Link to comment Share on other sites More sharing options...
lonewolf217 Posted March 30, 2009 Share Posted March 30, 2009 code is basically correct. where $money comes from is entirely up to you though based on your "game" Quote Link to comment Share on other sites More sharing options...
Rdogg112 Posted March 30, 2009 Author Share Posted March 30, 2009 what could i acctualy put in $money? Quote Link to comment Share on other sites More sharing options...
lonewolf217 Posted March 30, 2009 Share Posted March 30, 2009 um, how about a value of how much money you are searching for ? Quote Link to comment Share on other sites More sharing options...
Rdogg112 Posted March 30, 2009 Author Share Posted March 30, 2009 what do you mean how much money im searching for? Quote Link to comment Share on other sites More sharing options...
lonewolf217 Posted March 30, 2009 Share Posted March 30, 2009 i suggest you start with the basics. like what you want to do with your game, and how to use SQL queries . http://www.tizag.com/phpT/index.php http://www.tizag.com/sqlTutorial/ Once you understand what you are talking about, then you can get specific help Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted April 28, 2011 Share Posted April 28, 2011 You don't want to search WHERE money = $money in the first place! search where userID = $userID (or simmilar) if you knew the value of $money you wouldn need to ask the database what is would you? Quote Link to comment Share on other sites More sharing options...
PaulRyan Posted April 28, 2011 Share Posted April 28, 2011 Your code is almost correct, you need to get the money based on the logged in users ID or username. $sql = mysql_query("SELECT money FROM `users` WHERE id = {$user['id']}"); if($sql) { $blah = mysql_fetch_assoc($sql); echo 'Money: '. $blah['money']; } else } echo 'This Query Failed: '.mysql_error(); } Try the above, but change the $user['id'] to the method you are using to identify a user. Regards, PaulRyan. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted April 28, 2011 Share Posted April 28, 2011 This is a two year old thread that got bumped by sdfpw to post a link. Quote Link to comment Share on other sites More sharing options...
PaulRyan Posted April 28, 2011 Share Posted April 28, 2011 Well spotted...I feel such an idiot now 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.