GRooVeZ Posted April 17, 2012 Share Posted April 17, 2012 hi i made my very first array, and its working great now i want to have another array wich does the same thing, but on another category, it shows gold silver and bronze logos, but now i want to give leaders of other categorys also those logos, but different ones so i thought i change from $array[$snipergameid][$x] = $sniperleaders[playerid]; (part of the code in a while loop) into $array2[$snipergameid][$x] = $sniperleaders[playerid]; (part of the code in a while loop) and i do the same for the result checker loops but that doesnt work so how do i copy an entire arrray, and give it another name to match it with the correct while loop checker? Quote Link to comment https://forums.phpfreaks.com/topic/261139-copy-an-array/ Share on other sites More sharing options...
xyph Posted April 17, 2012 Share Posted April 17, 2012 You're doing something really wrong here. Please, give us more details into what you're trying to accomplish, rather than how you've decided to accomplish it. Quote Link to comment https://forums.phpfreaks.com/topic/261139-copy-an-array/#findComment-1338270 Share on other sites More sharing options...
GRooVeZ Posted April 17, 2012 Author Share Posted April 17, 2012 $sniperchecker = mysql_query ("SELECT id FROM `ffa_games`"); while($snipergames = mysql_fetch_array($sniperchecker)) { $snipergameid = $snipergames[id]; $x = 1; $sniperchecker2 = mysql_query ("SELECT playerid FROM ffa_rankings where gameid=$snipergameid and typeid=2 order by points desc"); while($sniperleaders = mysql_fetch_array($sniperchecker2)) { $array[$snipergameid][$x] = $sniperleaders[playerid]; $x++; } } $snipergameschecker2 = mysql_query ("SELECT id FROM `ffa_games`"); while($snipergames2 = mysql_fetch_array($snipergameschecker2)) { $snipergameid2 = $snipergames2[id]; if ($mem[id] == $array[$snipergameid2][1]) { $out[body].=" <img src='./images/icons/sniper1.png' title='Leader in a Sniper Ranking'>"; } if ($mem[id] == $array[$snipergameid2][2]) { $out[body].=" <img src='./images/icons/sniper2.png' title='2nd in a Sniper Ranking'>"; } if ($mem[id] == $array[$snipergameid2][3]) { $out[body].=" <img src='./images/icons/sniper3.png' title='3th in a Sniper Ranking'>"; } } this is the array i made, wich is working now i want another one, and i did this $sniperchecker = mysql_query ("SELECT id FROM `ffa_games`"); while($snipergames = mysql_fetch_array($sniperchecker)) { $snipergameid = $snipergames[id]; $x = 1; $sniperchecker2 = mysql_query ("SELECT playerid FROM ffa_rankings where gameid=$snipergameid and typeid=2 order by points desc"); while($sniperleaders = mysql_fetch_array($sniperchecker2)) { $array[$snipergameid][$x] = $sniperleaders[playerid]; $x++; } $allgunschecker2 = mysql_query ("SELECT playerid FROM ffa_rankings where gameid=$snipergameid and typeid=1 order by points desc"); while($allgunsleaders = mysql_fetch_array($allgunschecker2)) { $array2[$snipergameid][$x] = $allgunsleaders[playerid]; $x++; } } $snipergameschecker2 = mysql_query ("SELECT id FROM `ffa_games`"); while($snipergames2 = mysql_fetch_array($snipergameschecker2)) { $snipergameid2 = $snipergames2[id]; if ($mem[id] == $array[$snipergameid2][1]) { $out[body].=" <img src='./images/icons/sniper1.png' title='Leader in a Sniper Ranking'>"; } if ($mem[id] == $array[$snipergameid2][2]) { $out[body].=" <img src='./images/icons/sniper2.png' title='2nd in a Sniper Ranking'>"; } if ($mem[id] == $array[$snipergameid2][3]) { $out[body].=" <img src='./images/icons/sniper3.png' title='3th in a Sniper Ranking'>"; } if ($mem[id] == $array2[$snipergameid2][1]) { $out[body].=" <img src='./images/icons/ak1.png' title='Leader in a Sniper Ranking'>"; } if ($mem[id] == $array2[$snipergameid2][2]) { $out[body].=" <img src='./images/icons/ak2.png' title='2nd in a Sniper Ranking'>"; } if ($mem[id] == $array2[$snipergameid2][3]) { $out[body].=" <img src='./images/icons/ak.png' title='3th in a Sniper Ranking'>"; } } Quote Link to comment https://forums.phpfreaks.com/topic/261139-copy-an-array/#findComment-1338274 Share on other sites More sharing options...
AyKay47 Posted April 18, 2012 Share Posted April 18, 2012 I can't even decipher the logic behind your code, it's a mess. 1. you should be joining queries together instead of querying inside of a while loop, this will save resources and cut down on server load times. Please explain in English exactly what you are trying to do so we can assist you further. Quote Link to comment https://forums.phpfreaks.com/topic/261139-copy-an-array/#findComment-1338380 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.