The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

I wanna combine tables!

2 posters

Go down

I wanna combine tables! Empty I wanna combine tables!

Post by Voxie March 20th 2017, 6:03 pm

hello guys i just basically saw some good website who alrdy combined 9 servers tables in 1 table including all votes from all server which is something perfect and i tried to do but i can't seem to work it out ! so

the links of tables i have are


https://ark-servers.net/api/?object=servers&element=voters&key=jwoy226r9qo29rxid0a9vg65pno4s9bsf29&month=current&format=json
https://ark-servers.net/api/?object=servers&element=voters&key=4knryax7ibqp789k3tzjjjbmkxkl5ns9dh&month=current&format=json
https://ark-servers.net/api/?object=servers&element=voters&key=7w41ryvms91repwbef222ccqsnoutiurray&month=current&format=json



And i basically want these 3 tables there to be all in 1 table combined with all counts

Lets say Target 1 Had on the first link 50 vote and on the second link 30 vote and the third 1 that makes it overall 81 Please someone help me solve that Smile i would be appreciated!

this was the java code i used

Code:
<script>
   
   var votingURLs = [   
   'https://ark-servers.net/api/?object=servers&element=voters&key=jwoy226r9qo29rxid0a9vg65pno4s9bsf29&month=current&format=json',
   'https://ark-servers.net/api/?object=servers&element=voters&key=4knryax7ibqp789k3tzjjjbmkxkl5ns9dh&month=current&format=json',
   'https://ark-servers.net/api/?object=servers&element=voters&key=7w41ryvms91repwbef222ccqsnoutiurray&month=current&format=json',
   ];
   
   var votingLists = [];
   
   var counter = 0;
   
   var finalList = [];
   
   var voters = [];
   var votesOfVoters = [];
   
   
   $(document).ready(function () {
      

      $.each(votingURLs, function( index, value ) {
         
         
         var data;
         $.ajax({
            dataType: "json",
            url: value,
            data: data,
            success: function (data) {

               console.log(data.voters);
               votingLists[index] = data.voters;
               

               checkCompleteness();
            }
         });
            
      });
   });
   
   
   
   function checkCompleteness(){
      counter++;
         
      if(counter==(votingURLs.length)){
         evalData();
      }
   }
   
   
   function evalData(){
      console.log("Start Evaluating");
      finalList = votingLists[0];
      

      $.each(votingLists, function(index, list){
         if(index > 0){
            
      
            $.each(list, function(index, value){
               

               var name = value.nickname;
               var found = false;         
               
      
               $.each(finalList, function(indexF, valueF){
                  


                  if(name == valueF.nickname){

                     valueF.votes = parseInt(valueF.votes) + parseInt(value.votes);
                     found = true;
                     return false;
                     
                  }
               });
               
               //If not found, add it to the list
               if(!found){
                  finalList.push(value);
               }
            });
            
            
         }
      });
   
      displayingList(finalList);
   }
   
   
   
   function displayingList(list){
      console.log("Start Displaying");
      
      list.sort(function(a,b) {


           return parseInt(b.votes,10) - parseInt(a.votes,10);

      });
      
      $.each(list, function(index, value){
         

         var row = '<tr> <td>' + value.nickname + '</td> <td> ' + value.votes + '</td> </tr>';
         $('table[data="votingList"] tbody').append(row);
      });
   }
   </script>



avatar
Voxie
New Member

Male Posts : 9
Reputation : 2
Language : English

Back to top Go down

I wanna combine tables! Empty Re: I wanna combine tables!

Post by Voxie March 20th 2017, 6:26 pm

I just made it i solved it thanks al ot Smile!
avatar
Voxie
New Member

Male Posts : 9
Reputation : 2
Language : English

Back to top Go down

I wanna combine tables! Empty Re: I wanna combine tables!

Post by SLGray March 20th 2017, 6:38 pm

Since the solution was not posted, this topic will be sent to the garbage.


I wanna combine tables! Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51463
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum