|
-
Who needs pants?
Advanced INSERT and SELECT queries?
I really cant wrap my head around how to write queries that use more then one table.
What im trying to do is set up a account for a player. So when they register it set up in members table. Things like id, username, name, age and so on and then using that id insert into another game_table of their game profile. id, level, health, ...
How do i write something like this in one query. Initially when they register all the values in the game_table will be their default values so i only need to create a row where the id = the id from the members_table and the rest of the values default.
And when a user logs in i have a select query that searches the members table to see if the username and password feilds match but i also want to retrieve the values from the game_table for the same id.
I have a rough idea of how it works but when i try writing it...
So basically i want to select everything in the game_table where game.id = members.id only if members.username = $_post(username) and members.password = $_Post(password)
Hope this makes sense
-
associate
-
Something like:
Code:
$uname = mysql_real_escape_string($_POST['username']);
$passwd = mysql_real_escape_string($_POST['password']);
$sql = "SELECT game_table.* FROM game_table INNER JOIN members ON members.id=game_table.id WHERE members.username='$uname' AND members.password='$passwd'";
-
Who needs pants?
Thanks for the replies guys. Helped out alot.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|