TheJoey Posted October 7, 2009 Share Posted October 7, 2009 Hi im having trouble trying to create a querry that will retrieve codeID, Firstname & lastname of people i have playing on my server that only play pacman, then displays how many times they have played it. Quote Link to comment https://forums.phpfreaks.com/topic/176778-sql-querry-help/ Share on other sites More sharing options...
Coreye Posted October 7, 2009 Share Posted October 7, 2009 What problems are you having? Post the code and we'll be able to help you better... Quote Link to comment https://forums.phpfreaks.com/topic/176778-sql-querry-help/#findComment-932097 Share on other sites More sharing options...
TheJoey Posted October 7, 2009 Author Share Posted October 7, 2009 Besides from the simple Select CodeID, Firstname, Lastname FROM GAMERS ive very new to querrys. Any help very much appeciated, and its the only sql i use in my whole website.. im only trying to test something. Quote Link to comment https://forums.phpfreaks.com/topic/176778-sql-querry-help/#findComment-932357 Share on other sites More sharing options...
kickstart Posted October 7, 2009 Share Posted October 7, 2009 Hi From the very basics. Firstly you need to connect to the database server, using a userid and password. Something like:- $dbhost = 'www.mydb.com'; $dbuser = 'myUserid'; $dbpasswd = 'myPassword'; $conn = mysql_connect($dbhost,$dbuser,$dbpasswd); Then select the actual database:- $dbname = 'myDatabaseName'; mysql_select_db($dbname,$conn ) or die('Could not select database.'.mysql_error()); Then set up your piece of SQL. $sql = "Select CodeID, Firstname, Lastname FROM GAMERS"; Execute the SQL, bringing back a result:- $result = mysql_query($sql); Then loop around bring back each row until you have processed them all / processed the ones you care about. This is executing mysql_fetch_assoc which grabs the next row from $result and puts it into an associative array which is assigned to $row. while( $row = mysql_fetch_assoc($result) ) { echo $row['CodeID']." ".$row['Firstname']." ".$row['Lastname']; } Hope those basics help. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/176778-sql-querry-help/#findComment-932376 Share on other sites More sharing options...
TheJoey Posted October 8, 2009 Author Share Posted October 8, 2009 Thanks how would i run the sql so just show people who play pacman Quote Link to comment https://forums.phpfreaks.com/topic/176778-sql-querry-help/#findComment-932776 Share on other sites More sharing options...
corbin Posted October 8, 2009 Share Posted October 8, 2009 What does your database layout look like? Quote Link to comment https://forums.phpfreaks.com/topic/176778-sql-querry-help/#findComment-932790 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.