theagemaway Posted September 24, 2006 Share Posted September 24, 2006 hey i gots a question.im not that great at PHP, but im workin at it. can anyone tell me if this is possible?Im making a game out of PHP/HTML, and what I want to do is store all the users and all the variables associated with that user in a MySQL table. simple, easy. now the tricky part is this. I want to load any certain user out of mysql and make that user into an object, and preserve all the columns that represent all the variables of that user.here's what I meansql table:[font=courier]|----------|------|-------|| username | pass | email ||----------|------|-------||-theagema-|-way--|-bob@y-||----------|------|-------|[/font]I want to be able to do something like$guy = new User($POST_['username']);echo $guy->username . "<br />";echo $guy->pass . "<br />";echo $guy->email . "<br />";results in theagemawaybob@ythis is what i have so far.--- code ---class user { public $username; public $userinfo; function __construct($username) { $this->username = $username; $query = "SELECT * FROM users WHERE username='$this->username'"; $result = mysql_query($query); $userinfo = mysql_fetch_array($result); }}--- end code ---i dont think i have that code correct. but anyways, can someone help me devise a way to do this dynamically, and effectively? thanks :) 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.