cliftonbazaar Posted September 13, 2017 Share Posted September 13, 2017 So I have two tables (one small, one large), the first table is called 'profile' and has each players name, the second table is called 'toon' and has each players characters. What I am trying to do is output the players (which is easy to do with mysqli_fetch_array) but I also wish to output some of the players toons with their power level. table 'profile' 1 James 2 Darren table 'toons' 1 Batman 456 1 Superman 789 2 Batman 1245 2 Superman 564 The output I want is NAME BATMAN SUPERMAN James 456 789 Darren 1245 564 Obviously this is a simplication of what I am doing Currently I was looping through all the profiles and then inside each loop calling each row of the toon I wanted but I soon realised that there must be a better way than making 1,500 calls to the database! James Quote Link to comment https://forums.phpfreaks.com/topic/304972-putting-a-persons-data-into-an-array/ Share on other sites More sharing options...
Barand Posted September 13, 2017 Share Posted September 13, 2017 You should use a query with a JOIN on the two tables using the users' ids Quote Link to comment https://forums.phpfreaks.com/topic/304972-putting-a-persons-data-into-an-array/#findComment-1551235 Share on other sites More sharing options...
cliftonbazaar Posted September 13, 2017 Author Share Posted September 13, 2017 JOIN is easy if they were the only toons in the database but they are not, in fact they can be out of order for some players Quote Link to comment https://forums.phpfreaks.com/topic/304972-putting-a-persons-data-into-an-array/#findComment-1551241 Share on other sites More sharing options...
cliftonbazaar Posted September 17, 2017 Author Share Posted September 17, 2017 Sorry to have to bump but I cannot work out how to display the answers; I can do the JOIN but not display the answers how I need Quote Link to comment https://forums.phpfreaks.com/topic/304972-putting-a-persons-data-into-an-array/#findComment-1551411 Share on other sites More sharing options...
Barand Posted September 17, 2017 Share Posted September 17, 2017 JOIN is easy if they were the only toons in the database but they are not, in fact they can be out of order for some players For the benefit of those of us who cannot see your data therefore can not understand your problem, perhaps you should provide a better explanation of the situation and your expected results. Quote Link to comment https://forums.phpfreaks.com/topic/304972-putting-a-persons-data-into-an-array/#findComment-1551427 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.