I need to create an dynamic array which will be sent via $("#ratings").load("ratingscalculator.php?Myarray="+myarray)
and then used in a select query
$result = $database->connection->prepare("SELECT *, (SELECT COUNT(*)+1 FROM TABLE WHERE kampanj > t.kampanj and (kampanjnamn = 'Kampanjnamn_1' or kampanjnamn = 'Kampanjnamn_7' or kampanjnamn = 'Kampanjnamn_3' or kampanjnamn = 'Kampanjnamn_4' )) as 'rank',
(SELECT COUNT(*) FROM TABLE where (kampanjnamn = 'Kampanjnamn_1' or kampanjnamn = 'Kampanjnamn_7' or kampanjnamn = 'Kampanjnamn_3' or kampanjnamn = 'Kampanjnamn_4') ) as 'counting'
FROM TABLE t
where kampanjnamn='$valtkampanjnamn'");
So it's this bit that I need to dynamically create somehow (kampanjnamn = 'Kampanjnamn_1' or kampanjnamn = 'Kampanjnamn_7' or kampanjnamn = 'Kampanjnamn_3' or kampanjnamn = 'Kampanjnamn_4' )
(this is just an example on what it would contain as it is user selectable)
So I want to create an array of all elements with the class "focused" and get their data-attribute "kampanjnamn".
My best guess would be something like this inside a click function:
$('.focused').each(function () {
var Myarray = [];
Myarray = $(this).data('kampanjnamn');
}
this gives me the error "Myarray is not defined". If I put window. infront instead of var it send the variable as a single object and not an array...
So my first question maybe should have been: Is it even possible to send an array with .load?