[Solved] Get all unique values in a JavaScript array (remove duplicates)

With JavaScript 1.6 / ECMAScript 5 you can use the native filter method of an Array in the following way to get an array with unique values: function onlyUnique(value, index, self) { return self.indexOf(value) === index; } // usage example: var a = [‘a’, 1, ‘a’, 2, ‘1’]; var unique = a.filter(onlyUnique); console.log(unique); // [‘a’, … Read more

[Solved] How to randomly pick a number of combinations from all the combinations efficiently

If you have F unique first names and L unique last names, then overall number of combinations is N = F * L So you can generate needed number of non-repeating random integer values in range 0..N-1 (for example, with Fisher-Yates sampling), sort them, and get corresponding name combinations: for i = 0..M-1 Generate K[i] … Read more

[Solved] MYSQL/PHP SELECT DISTINCT

Looks like the query is actually pulling 3 results as it should. You are just letting one of them go: function adminnav (){ $pagewcoms = mysql_query(…); // HERE YOU FETCH ONE ROW BUT DO NOTHING WITH IT $idnavrow = mysql_fetch_row($pagewcoms); while ($itest = mysql_fetch_row($pagewcoms)) { echo “$itest[0] <br />”; } } If you just remove … Read more

[Solved] Count unique words in table with JS [closed]

Here how I would do it using JavaScript. This code calculates words for whole table. If you need to run it for the row, you should modify it appropriately. var words = []; var uniqueWords = []; $(“td”).each(function(){ words.push($(this).text()) }); $(words).each(function(){ for(var i = 0; i < uniqueWords.length; i++){ var current = uniqueWords[i]; if(current.word.toString() == … Read more

[Solved] How retrieve specific duplicate array values with PHP

If you need do search thru yours array by $id: foreach($array as $value) { $user_id = $value[“id”]; $userName = $value[“name”]; $some_key++; $users_array[$user_id] = array(“name” => $userName, “upline” => ‘1’); } function get_downline($user_id, $users_array){ foreach($users_array as $key => $value) { if($key == $user_id) { echo $value[“name”]; …do something else….. } } } or to search by … Read more